public inbox for gcc-prs@sourceware.org help / color / mirror / Atom feed
From: jason-gccprs@molenda.com To: gcc-gnats@gcc.gnu.org Subject: c/5957: gcc accepts C99-only code even when -std=c89 arg used Date: Wed, 13 Mar 2002 19:06:00 -0000 [thread overview] Message-ID: <20020314030209.7684.qmail@sources.redhat.com> (raw) >Number: 5957 >Category: c >Synopsis: gcc accepts C99-only code even when -std=c89 arg used >Confidential: no >Severity: serious >Priority: medium >Responsible: unassigned >State: open >Class: sw-bug >Submitter-Id: net >Arrival-Date: Wed Mar 13 19:06:00 PST 2002 >Closed-Date: >Last-Modified: >Originator: Jason Molenda >Release: gcc-3_1-branch >Organization: >Environment: >Description: When gcc is given a source file like the following: #include <stdio.h> int main () { puts ("hi"); int f; } which is invalid in ISO C89 or the 1994 Amendment, it will accept the code even if -std=c89 is given on the command line. If -pedantic is added, it will issue a pedwarn, ISO C89 forbids mixed declarations and code but I'd argue that this is not sufficient. If I pass -std=c89 to gcc, I expect that the code which compiles will also compile for Bob down the hall, who is stubborn and refuses to upgrade beyond gcc 2.95. I can understand that gcc can't provide a genuinely ISO C89 environment when C99-only headers may be present, but it should be able to handle this one. Inside gcc, the flag_isoc94, flag_isoc99 variables which one might try to use to catch this error, seem to be intended only to indicate additional capabilities that should be recognized. i.e. I don't see a way in c-parse.in to detect that the user is requesting a specifically restricted set of C constructs with the current set of flags. gcc 3.1's behavior in this case by default is also confusing. I guess gcc is in "g89" mode by default, so if you need to add "-std=c99" to explicitly put yourself in ISO C99 mode. But you can use C99 features like variable-decls-after-statements-in-a-block in the "g89" mode (which wouldn't have worked with 2.95's g89 mode). >How-To-Repeat: >Fix: Recognize in c-decl.c when the user is explicitly asking for c89 or c94 mode, and issue an error() when c99-specific constructs are used in the source. >Release-Note: >Audit-Trail: >Unformatted:
next reply other threads:[~2002-03-14 3:06 UTC|newest] Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top 2002-03-13 19:06 jason-gccprs [this message] 2002-03-29 0:50 neil 2002-04-20 10:36 Craig Rodrigues
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20020314030209.7684.qmail@sources.redhat.com \ --to=jason-gccprs@molenda.com \ --cc=gcc-gnats@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).