From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20722 invoked by alias); 14 Mar 2002 03:06:00 -0000 Mailing-List: contact gcc-prs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-prs-owner@gcc.gnu.org Received: (qmail 20681 invoked by uid 71); 14 Mar 2002 03:06:00 -0000 Resent-Date: 14 Mar 2002 03:06:00 -0000 Resent-Message-ID: <20020314030600.20680.qmail@sources.redhat.com> Resent-From: gcc-gnats@gcc.gnu.org (GNATS Filer) Resent-To: nobody@gcc.gnu.org Resent-Cc: gcc-prs@gcc.gnu.org, gcc-bugs@gcc.gnu.org Resent-Reply-To: gcc-gnats@gcc.gnu.org, jason-gccprs@molenda.com Received:(qmail 7685 invoked by uid 61); 14 Mar 2002 03:02:09 -0000 Message-Id:<20020314030209.7684.qmail@sources.redhat.com> Date: Wed, 13 Mar 2002 19:06:00 -0000 From: jason-gccprs@molenda.com Reply-To: jason-gccprs@molenda.com To: gcc-gnats@gcc.gnu.org X-Send-Pr-Version:gnatsweb-2.9.3 (1.1.1.1.2.31) Subject: c/5957: gcc accepts C99-only code even when -std=c89 arg used X-SW-Source: 2002-03/txt/msg00468.txt.bz2 List-Id: >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 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: