From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 1014db,cb40752a27f3d651 X-Google-Attributes: gid1014db,public X-Google-Thread: 1164f8,cb40752a27f3d651 X-Google-Attributes: gid1164f8,public X-Google-Thread: fee84,cb40752a27f3d651 X-Google-Attributes: gidfee84,public From: kaz@ashi.FootPrints.net (Kaz Kylheku) Subject: Re: comma operator: C compiler bug or bogus usage? Date: 1999/04/15 Message-ID: #1/1 X-Deja-AN: 466862536 References: <7f567v$sp1$1@news.iastate.edu> <7f5fvl$ujn$1@news.iastate.edu> X-Trace: newsgate.direct.ca 924210019 204.239.179.1 (Thu, 15 Apr 1999 14:00:19 PDT) Organization: Psycho-Neurotic Institute for The Very, Very Nervous NNTP-Posting-Date: Thu, 15 Apr 1999 14:00:19 PDT Newsgroups: comp.lang.c,comp.unix.osf.osf1,comp.sys.dec On 15 Apr 1999 19:51:17 GMT, John Hascall wrote: >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 :) The -ansi option just means to disable GCC extensions that would cause ansi programs to be rejected or diagnosed. The -pedantic option is needed to further comply with ANSI C by generating required diagnostics for syntax and constraint violations. That (outdated) man page is just GNU propaganda: ``there is no reason to use this option; it exists only to satisfy pedants''. This is, of course, nonsense. The list of syntax and constraint violations required by ANSI C is not all that extensive; to say that only a pedant would want these diagnostics is laughable. If your compiler doesn't diagnose an ANSI C syntax or constraint violation, the code may well be rejected by another compiler. Or the lack of diagnosis may even cause a defect to go undetected. You see, the FSF guys want everyone to write in GNU C, that is, using the GCC extensions, so that the code won't compile with those evil non-freeware compilers that nobody should be using now that there is GCC. :)