From: john@iastate.edu (John Hascall)
Subject: Re: comma operator: C compiler bug or bogus usage?
Date: 1999/04/15 [thread overview]
Message-ID: <7f5fvl$ujn$1@news.iastate.edu> (raw)
In-Reply-To: slrn7hcc84.4k7.kaz@ashi.FootPrints.net
Kaz Kylheku <kaz@ashi.FootPrints.net> 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
next prev parent reply other threads:[~1999-04-15 4:00 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
1999-04-15 4:00 comma operator: C compiler bug or bogus usage? John Hascall
1999-04-15 4:00 ` Casper H.S. Dik - Network Security Engineer
1999-04-15 4:00 ` Kaz Kylheku
1999-04-15 4:00 ` John Hascall [this message]
1999-04-15 4:00 ` Kaz Kylheku
1999-04-16 4:00 ` Lawrence Kirby
1999-04-15 4:00 ` Lawrence Kirby
1999-04-15 4:00 ` Joerg Czeranski
1999-04-15 4:00 ` Will Rose
1999-04-15 4:00 ` Venkat
1999-04-15 4:00 ` Noone Really
read-only archive
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox