🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.gcc.help
Article #929

Is this a compiler bug?

#929
From: Edward J. Huff
Date: Thu, 29 Feb 1996 19:30
50 lines
1807 bytes
The gcc documentation states:
> If the compiler does not produce an error message for invalid 
> input, that is a compiler bug. However, you should note that 
> your idea of "invalid input" might be my idea of "an extension"
> or "support for traditional practice".

Is this a bug?  Or is it "support for traditional practice"?

carbon% head static*.c
==> static_bug.c <==
static const char foo[];

int
main(int argc, const char *argv[]) {
  printf("foo = '%s'\n",foo);
  return 0;
}

#ifdef DEFINE_IT
static const char foo[] = "bar";
#endif

==> static_bug2.c <==
const char foo[] = "baz";
carbon% gcc static*.c
carbon% a.out
foo = 'baz'
carbon% gcc -DDEFINE_IT static*.c
carbon% a.out
foo = 'bar'

The above happens on 
GNU C version 2.6.3 (sparc) compiled by GNU C version 2.6.3.
running on
SunOS carbon 5.5 Generic sun4m sparc SUNW,SPARCstation-20
and identically on
GNU C version 2.7.2 [AL 1.1, MM 40] SGI running IRIX 5.x compiled by CC.
running on 
IRIX archimedes 5.3 11091810 IP17 mips.

The IRIX C compiler gives an error:

archimedes 23% cc static*.c
static_bug.c:
cfe: Error: static_bug.c, line 1: storage size for 'foo' isn't known
 static const char foo[];
 ------------------^

--
huffe@carbon.chem.nyu.edu (Edward J. Huff) 212-998-8465
Technical Details
Message-ID: <3135FEDB.65AA@carbon.chem.nyu.edu>
Path: arc1-ca.pugleaf.net!newsfeed.internetmci.com!panix!cmcl2!news!usenet

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!newsfeed.internetmci.com!panix!cmcl2!news!usenet
From: "Edward J. Huff" <huffe@carbon.chem.nyu.edu>
Newsgroups: gnu.gcc.help,comp.lang.c
Subject: Is this a compiler bug?
Date: Thu, 29 Feb 1996 14:30:35 -0500
Organization: New York University Chemistry Dept
Message-ID: <3135FEDB.65AA@carbon.chem.nyu.edu>
NNTP-Posting-Host: carbon.chem.nyu.edu
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
X-Mailer: Mozilla 2.0 (X11; I; SunOS 5.5 sun4m)