From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 1164f8,cb40752a27f3d651 X-Google-Attributes: gid1164f8,public X-Google-Thread: 1014db,cb40752a27f3d651 X-Google-Attributes: gid1014db,public X-Google-Thread: fee84,cb40752a27f3d651 X-Google-Attributes: gidfee84,public From: john@iastate.edu (John Hascall) Subject: Re: comma operator: C compiler bug or bogus usage? Date: 1999/04/15 Message-ID: <7f5fvl$ujn$1@news.iastate.edu>#1/1 X-Deja-AN: 466842938 References: <7f567v$sp1$1@news.iastate.edu> Organization: Iowa State University, Ames, Iowa USA Newsgroups: comp.lang.c,comp.unix.osf.osf1,comp.sys.dec Kaz Kylheku wrote: }>int bar[3,4]; }> constant-expression comma-operator constant-expression }> still a constant-expression or not? If not, why not ... }It's certainly an expression with a value that can be determined at compile }time, no argument there. However, that is not the same as a constant }expression. The latter is just a term that is arbitrarily defined in the C }standard. You have to apply that definition to determine whether something }is a constnat expression or not. Ah, silly me, the Humpty-Dumpty privilege! }>John }>PS, FWIW, gcc accepts both of these and produces the 'expected' results }It does not if you tell it to be an ANSI C compiler witn -ansi -pedantic. Actually I tried it with -ansi -Wall but the man page scared me away from -pedantic :) }I tried it with egcs 2.91.57, which accepts it without the -pedantic }option, but produces the following warning if you turn on -pedantic: } } warning: ANSI C forbids variable-size array 'a'. } }You have fallen into a common pitfall by assuming that your compiler is a C }compiler by default. Many compilers default to supporting their implementor's }extensions, with ANSI C support being a negative option. For example, the }Microsoft compiler supports transparent unions and // comments by }default. GCC supports // comments, statement blocks that behave like }expressions, array sizes that are computed at run time, nested functions and }other goodies. Heh, well any compiler that defaults to trigraphs off gets my cheers! John -- John Hascall, Software Engr. Shut up, be happy. The conveniences you ISU Computation Center demanded are now mandatory. -Jello Biafra mailto:john@iastate.edu http://www.cc.iastate.edu/staff/systems/john/index.html <=- the usual crud