https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61854

Harald van Dijk <harald at gigawatt dot nl> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |harald at gigawatt dot nl

--- Comment #2 from Harald van Dijk <harald at gigawatt dot nl> ---
(In reply to Manuel López-Ibáñez from comment #1)
> Perhaps GCC should accept // without comment unless -Wpedantic. The current
> error is nonsensical.

The point of the -std=c89 option is that if a program is valid C89, GCC will
accept it in that mode. Extensions that don't conflict with the standard are
enabled without any diagnostic unless -pedantic is also passed. Extensions that
do conflict with the standard are disabled. // comments are an extension that
conflicts with the standard, so should not be enabled. A C89+extensions mode
already exists, that's what -std=gnu89 (the default mode) does. Example
program:

int main() {
  return 1 //**/ 2
    ;
}

C89 requires this to return zero, and gcc -std=c89 does correctly make this
return zero. gcc -std=gnu89 makes this return 1. (More realistically, enabling
// comments could cause GCC to reject valid code as having syntax errors where
there are none.)

The request in this bug report does make sense to me: if GCC detects a syntax
error in c89 mode, and the syntax error is caused by an unexpected / token that
immediately follows another / token, it would make sense to treat that as a
special case. Handling it only when there is an error will not cause valid code
to be rejected.

Reply via email to