Path: csiph.com!eternal-september.org!feeder.eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.lang.c,comp.lang.c++ Subject: Re: Switching to C# Date: Sun, 16 Jun 2019 14:24:07 -0700 Organization: None to speak of Lines: 45 Message-ID: References: <5d03bb38.3305609877@core> <5d059fdf.3429680737@core> <5d05fa0f.3452768783@core> <5d067312.3483747362@core> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: reader02.eternal-september.org; posting-host="df4904b93ef33b63818a6c0a0a5ba2e4"; logging-data="17531"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18UlntVhYNo8ZS4yPZ/mYMT" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:Sqawt2mtSck9gcJ7ln7fEvM7Yd4= sha1:5jGXgewAhaena4YUfhMt3jIt0po= Xref: csiph.com comp.lang.c:144930 comp.lang.c++:66486 nobody@example.org (Scott) writes: > On Sun, 16 Jun 2019 02:24:25 -0700, Keith Thompson > wrote: >>nobody@example.org (Scott) writes: >>> On Sat, 15 Jun 2019 19:31:13 -0700, Keith Thompson >>> wrote: >>>>nobody@example.org (Scott) writes: >>> Apparently not a fatal one. gcc 7.4 with -std=c99 warns, but builds it >>> anyway. >> >>As I said, it's a constraint violation. That means that a conforming >>compiler must issue a diagnostic message. It's not required to be >>fatal. In fact the only construct that required a fatal error is the >>"#error" directive. (I personally wish gcc were more strict, but that's >>a whole 'nother kettle of fish.) >> >>The lesson is that warnings from C compilers should be taken *very* >>seriously. >> >>"gcc -std=c99 -pedantic" results in a fatal error. > > Hmm. Which gcc are you using? Mine (7.4.0) still gives a warning with > those flags. -pedantic-errors does give an error as I expected. I'm > not saying you're wrong, I'm just curious why we're seeing different > results with the same experiment. > > The source snippet I used is this: > > int main(void) { return 45 != foo("Hello", 2.5, 45); } > int foo(char *x, double y, int z) { return z; } Sorry, I messed that up. "gcc -std=c99" should correctly compile all correct C99 programs. "gcc -std=c99 -pedantic" should do the same and issue all required diagnostics. In this mode, it should be a conforming C99 compiler. "gcc -std=c99 -pedantic-errors" turns all required diagnostics into fatal errors. -- Keith Thompson (The_Other_Keith) kst-u@mib.org Will write code for food. void Void(void) { Void(); } /* The recursive call of the void */