public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/59668] New: extraneous error messages at -O1, -O2 and -O3 for valid code with string library functions
@ 2014-01-03 20:36 su at cs dot ucdavis.edu
2014-01-03 21:21 ` [Bug c/59668] " pinskia at gcc dot gnu.org
` (5 more replies)
0 siblings, 6 replies; 7+ messages in thread
From: su at cs dot ucdavis.edu @ 2014-01-03 20:36 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59668
Bug ID: 59668
Summary: extraneous error messages at -O1, -O2 and -O3 for
valid code with string library functions
Product: gcc
Version: 4.9.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: su at cs dot ucdavis.edu
The current trunk and older GCC versions reject the following code with odd
error messages at -O1, -O2 and -O3 (but not -O0 and -Os).
$ gcc-trunk -v
Using built-in specs.
COLLECT_GCC=gcc-trunk
COLLECT_LTO_WRAPPER=/usr/local/gcc-trunk/libexec/gcc/x86_64-unknown-linux-gnu/4.9.0/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: ../gcc-trunk/configure --prefix=/usr/local/gcc-trunk
--enable-languages=c,c++ --disable-werror --enable-multilib
Thread model: posix
gcc version 4.9.0 20140103 (experimental) [trunk revision 206321] (GCC)
$
$ gcc-trunk -Wall -Wextra -pedantic -std=c99 -c small.c
$
$ gcc-trunk -O0 -c small.c
$ gcc-trunk -Os -c small.c
$
$ gcc-trunk -O1 -c small.c
In file included from /usr/include/string.h:637:0,
from small.c:1:
small.c:3:5: error: expected identifier or ‘(’ before ‘__extension__’
int strcmp(const char *, const char *);
^
small.c:3:5: error: expected identifier or ‘(’ before ‘)’ token
int strcmp(const char *, const char *);
^
$
-----------------------
#include <string.h>
int strcmp(const char *, const char *);
>From gcc-bugs-return-439007-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Fri Jan 03 20:46:52 2014
Return-Path: <gcc-bugs-return-439007-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 5999 invoked by alias); 3 Jan 2014 20:46:51 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 5969 invoked by uid 48); 3 Jan 2014 20:46:48 -0000
From: "glisse at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c/59668] extraneous error messages at -O1, -O2 and -O3 for valid code with string library functions
Date: Fri, 03 Jan 2014 20:46:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: c
X-Bugzilla-Version: 4.9.0
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: glisse at gcc dot gnu.org
X-Bugzilla-Status: UNCONFIRMED
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org
X-Bugzilla-Target-Milestone: ---
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields:
Message-ID: <bug-59668-4-1ZfC8kKELz@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-59668-4@http.gcc.gnu.org/bugzilla/>
References: <bug-59668-4@http.gcc.gnu.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 7bit
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2014-01/txt/msg00149.txt.bz2
Content-length: 203
http://gcc.gnu.org/bugzilla/show_bug.cgi?idY668
--- Comment #1 from Marc Glisse <glisse at gcc dot gnu.org> ---
Well, that's a glibc issue, isn't it?
Btw, you need to provide the preprocessed code.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c/59668] extraneous error messages at -O1, -O2 and -O3 for valid code with string library functions
2014-01-03 20:36 [Bug c/59668] New: extraneous error messages at -O1, -O2 and -O3 for valid code with string library functions su at cs dot ucdavis.edu
@ 2014-01-03 21:21 ` pinskia at gcc dot gnu.org
2014-01-03 21:31 ` su at cs dot ucdavis.edu
` (4 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu.org @ 2014-01-03 21:21 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59668
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution|--- |INVALID
--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Actually this is neither a bug in GCC or glibc. In C, strcmp can be defined as
a macro and that is what you are getting a macro.
You can fix your code by doing:
int (strcmp)(const char *, const char *);
Instead.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c/59668] extraneous error messages at -O1, -O2 and -O3 for valid code with string library functions
2014-01-03 20:36 [Bug c/59668] New: extraneous error messages at -O1, -O2 and -O3 for valid code with string library functions su at cs dot ucdavis.edu
2014-01-03 21:21 ` [Bug c/59668] " pinskia at gcc dot gnu.org
@ 2014-01-03 21:31 ` su at cs dot ucdavis.edu
2014-01-03 21:39 ` pinskia at gcc dot gnu.org
` (3 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: su at cs dot ucdavis.edu @ 2014-01-03 21:31 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59668
--- Comment #3 from Zhendong Su <su at cs dot ucdavis.edu> ---
(In reply to Andrew Pinski from comment #2)
> Actually this is neither a bug in GCC or glibc. In C, strcmp can be defined
> as a macro and that is what you are getting a macro.
Huh, that's interesting; thanks. Could you give a pointer where this is
described?
But again, how come the inconsistent behaviors at different optimization
levels?
> You can fix your code by doing:
> int (strcmp)(const char *, const char *);
>
> Instead.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c/59668] extraneous error messages at -O1, -O2 and -O3 for valid code with string library functions
2014-01-03 20:36 [Bug c/59668] New: extraneous error messages at -O1, -O2 and -O3 for valid code with string library functions su at cs dot ucdavis.edu
2014-01-03 21:21 ` [Bug c/59668] " pinskia at gcc dot gnu.org
2014-01-03 21:31 ` su at cs dot ucdavis.edu
@ 2014-01-03 21:39 ` pinskia at gcc dot gnu.org
2014-01-03 21:47 ` su at cs dot ucdavis.edu
` (2 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu.org @ 2014-01-03 21:39 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59668
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|INVALID |DUPLICATE
--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Zhendong Su from comment #3)
> (In reply to Andrew Pinski from comment #2)
> > Actually this is neither a bug in GCC or glibc. In C, strcmp can be defined
> > as a macro and that is what you are getting a macro.
>
> Huh, that's interesting; thanks. Could you give a pointer where this is
> described?
It is described in the C standard but I don't have the exact reference number
for it though.
> But again, how come the inconsistent behaviors at different optimization
> levels?
Because glibc decides only to implement the macro at -O and above but not when
optimizing for size.
>
> > You can fix your code by doing:
> > int (strcmp)(const char *, const char *);
> >
> > Instead.
Anyways this is really a dup of bug 32449.
*** This bug has been marked as a duplicate of bug 32449 ***
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c/59668] extraneous error messages at -O1, -O2 and -O3 for valid code with string library functions
2014-01-03 20:36 [Bug c/59668] New: extraneous error messages at -O1, -O2 and -O3 for valid code with string library functions su at cs dot ucdavis.edu
` (2 preceding siblings ...)
2014-01-03 21:39 ` pinskia at gcc dot gnu.org
@ 2014-01-03 21:47 ` su at cs dot ucdavis.edu
2014-01-03 21:57 ` pinskia at gcc dot gnu.org
2014-01-03 22:56 ` schwab@linux-m68k.org
5 siblings, 0 replies; 7+ messages in thread
From: su at cs dot ucdavis.edu @ 2014-01-03 21:47 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59668
--- Comment #5 from Zhendong Su <su at cs dot ucdavis.edu> ---
> Because glibc decides only to implement the macro at -O and above but not
> when optimizing for size.
I see; thanks Andrew.
BTW, is strcmp the only one like this, or there are others?
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c/59668] extraneous error messages at -O1, -O2 and -O3 for valid code with string library functions
2014-01-03 20:36 [Bug c/59668] New: extraneous error messages at -O1, -O2 and -O3 for valid code with string library functions su at cs dot ucdavis.edu
` (3 preceding siblings ...)
2014-01-03 21:47 ` su at cs dot ucdavis.edu
@ 2014-01-03 21:57 ` pinskia at gcc dot gnu.org
2014-01-03 22:56 ` schwab@linux-m68k.org
5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu.org @ 2014-01-03 21:57 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59668
--- Comment #6 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Zhendong Su from comment #5)
> BTW, is strcmp the only one like this, or there are others?
Almost (if not all) all standard C functions are like this.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c/59668] extraneous error messages at -O1, -O2 and -O3 for valid code with string library functions
2014-01-03 20:36 [Bug c/59668] New: extraneous error messages at -O1, -O2 and -O3 for valid code with string library functions su at cs dot ucdavis.edu
` (4 preceding siblings ...)
2014-01-03 21:57 ` pinskia at gcc dot gnu.org
@ 2014-01-03 22:56 ` schwab@linux-m68k.org
5 siblings, 0 replies; 7+ messages in thread
From: schwab@linux-m68k.org @ 2014-01-03 22:56 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59668
--- Comment #7 from Andreas Schwab <schwab@linux-m68k.org> ---
7.1.3 Reserved identifiers
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2014-01-03 22:56 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-01-03 20:36 [Bug c/59668] New: extraneous error messages at -O1, -O2 and -O3 for valid code with string library functions su at cs dot ucdavis.edu
2014-01-03 21:21 ` [Bug c/59668] " pinskia at gcc dot gnu.org
2014-01-03 21:31 ` su at cs dot ucdavis.edu
2014-01-03 21:39 ` pinskia at gcc dot gnu.org
2014-01-03 21:47 ` su at cs dot ucdavis.edu
2014-01-03 21:57 ` pinskia at gcc dot gnu.org
2014-01-03 22:56 ` schwab@linux-m68k.org
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).