public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* (printf) ("hello world\n");
@ 2003-12-09 20:41 Michael Elizabeth Chastain
  2003-12-09 21:01 ` Dale Johannesen
  2003-12-09 23:56 ` Geoff Keating
  0 siblings, 2 replies; 19+ messages in thread
From: Michael Elizabeth Chastain @ 2003-12-09 20:41 UTC (permalink / raw)
  To: gcc

I have a language lawyer question.

  int main ()
  {
    (printf) ("hello world\n");
    return 0;
  }

Is this a conforming C program?

There is no "#include <stdio.h>" so there is no declaration
in scope for printf.

gcc 2.95.3 and gcc 3.3.2 both say:

  hello.c: In function `main':
  hello.c:3: `printf' undeclared (first use in this function)
  hello.c:3: (Each undeclared identifier is reported only once
  hello.c:3: for each function it appears in.)

This happens with each of:

  -std=iso9899:1990
  -std=iso9899:199409
  -std=iso9899:1999

But the HP ansi-c and aCC compilers accept it just fine.

This kind of code comes out of a macro expansion with readline 4.3
and gcc 3.3.2 on native hppa2.0w-hp-hpux11.11.  It's the end
result of an interaction between multibyte support in hpux11
and a strange-looking workaround in readline.

Of course the question "is this conforming ..." depends on a particular
standard.  So I think I am asking three questions, one for each of the
three standards.

If the program is not conforming, then I can work on a patch for
readline.  But if the program is conforming, then I can file a PR
against gcc (and I'll still have to patch readline).

(Personally I would be happier if this program is not conforming.)

Michael C

^ permalink raw reply	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2003-12-12 16:56 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-12-09 20:41 (printf) ("hello world\n"); Michael Elizabeth Chastain
2003-12-09 21:01 ` Dale Johannesen
2003-12-09 23:56 ` Geoff Keating
2003-12-10  9:53   ` Eyal Lebedinsky
2003-12-10 10:18     ` Andreas Schwab
2003-12-10 12:45       ` Robert Dewar
2003-12-10 13:12         ` Segher Boessenkool
2003-12-10 13:34           ` Robert Dewar
2003-12-10 13:36           ` Gabriel Dos Reis
2003-12-10 14:08           ` Joseph S. Myers
2003-12-10 14:17             ` Segher Boessenkool
2003-12-10 15:55               ` Andreas Schwab
2003-12-11 17:09               ` Geoff Keating
2003-12-11 17:39                 ` Segher Boessenkool
2003-12-12 13:07                 ` Jan-Benedict Glaw
2003-12-12 17:17                   ` Gabriel Dos Reis
2003-12-10 14:19             ` Register Spilling Umar Janjua
2003-12-11  7:59               ` Jim Wilson
2003-12-11  9:01                 ` Sanjiv Gupta

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).