🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.gcc.bug
Article #762

"const" confusion in gcc 1.36

#762
From: Andy Fyfe
Date: Fri, 27 Oct 1989 10:40
36 lines
1684 bytes
I wasn't expecting the first 3 warnings generated by gcc in the
test program that follows.  I may be misunderstanding "const"
(which, at this point, wouldn't surprise me).  It's not clear
to me what the last message means.  If the word "const" is
eliminated, then the program no longer parses.  Since it's a
bit weird, I thought I'd include it.

$ cat test.c
typedef char **ptr;

extern int exec1(const char *path, const char **args);
extern int exec2(const char *path, const ptr args);

one(char *p, char **q)
{
    exec1(p, (const char **)q);		/* ok */
    exec1(p, (const ptr)q);		/* not ok? */
    exec1(p, (const typeof(q))q);	/* not ok? */

    exec2(p, (const char **)q);		/* not ok? */
    exec2(p, (const ptr)q);		/* ok */
    exec2(p, (const typeof(q))q);	/* ok */

    exec1(p, (const (typeof(q)))q);	/* extra parens change things! */
}
$ gcc -v
gcc version 1.36
$ gcc -S test.c
test.c: In function one:
test.c:9: warning: argument passing between incompatible pointer types
test.c:10: warning: argument passing between incompatible pointer types
test.c:12: warning: argument passing between incompatible pointer types
test.c:16: conversion to non-scalar type requested
$ gcc -S -Dconst= test.c
test.c: In function one:
test.c:16: parse error before `)'
Technical Details
Message-ID: <8910271040.AA16447@csvax.caltech.edu>
Path: arc1-ca.pugleaf.net!utzoo!telly!attcan!utgpu!watmath!uunet!tut.cis.ohio-state.edu!CSVAX.CALTECH.EDU!andy

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!telly!attcan!utgpu!watmath!uunet!tut.cis.ohio-state.edu!CSVAX.CALTECH.EDU!andy
From: andy@CSVAX.CALTECH.EDU (Andy Fyfe)
Newsgroups: gnu.gcc.bug
Subject: "const" confusion in gcc 1.36
Message-ID: <8910271040.AA16447@csvax.caltech.edu>
Date: 27 Oct 89 10:40:01 GMT
Sender: daemon@tut.cis.ohio-state.edu
Distribution: gnu
Organization: GNUs Not Usenet
Lines: 36