public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/57345] New: Preprocessor fails to evaluation string token not valid
@ 2013-05-20 22:10 signupnathan at gmail dot com
2013-05-20 22:38 ` [Bug c/57345] " jakub at gcc dot gnu.org
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: signupnathan at gmail dot com @ 2013-05-20 22:10 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57345
Bug ID: 57345
Summary: Preprocessor fails to evaluation string token not
valid
Product: gcc
Version: 4.7.2
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: signupnathan at gmail dot com
This error
23L03.c: In function ‘main’:
23L03.c:16:10: error: token ""I know the C language.\n"" is not valid in
preprocessor expressions
23L03.c:20:10: error: token ""I know BASIC.\n"" is not valid in preprocessor
expressions
Is generated by the following code that compliles fine with clang. Code comes
from a book teaching about C in a preprocessor chapter.
#include <stdio.h>
#define C_LANG 'C'
#define B_LANG 'B'
#define NO_ERROR 0
int main(void)
{
#if C_LANG == 'C' && B_LANG == 'B'
#undef C_LANG
#define C_LANG "I know the C language.\n"
#undef B_LANG
#define B_LANG "I know BASIC.\n"
printf("%s%s", C_LANG, B_LANG);
#elif C_LANG == 'C'
#undef C_LANG
#define C_LANG "I only know C language.\n"
printf("%s", C_LANG);
#elif B_LANG == 'B'
#undef B_LANG
#define B_LANG "I only know BASIC.\n"
printf("%s", B_LANG);
#else
printf("I don't know C or BASIC.\n");
#endif
return NO_ERROR;
}
The preprocessor balks at this type of statement:
#if "foo" == "foo"
printf("foo matches");
#endif
>From gcc-bugs-return-422687-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Mon May 20 22:19:18 2013
Return-Path: <gcc-bugs-return-422687-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 20052 invoked by alias); 20 May 2013 22:19:18 -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 19514 invoked by uid 48); 20 May 2013 22:19:13 -0000
From: "pinskia at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c/57345] Preprocessor fails to evaluation string token not valid
Date: Mon, 20 May 2013 22:19: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.7.2
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: pinskia 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-57345-4-vgwITw8Aos@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-57345-4@http.gcc.gnu.org/bugzilla/>
References: <bug-57345-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: 2013-05/txt/msg01360.txt.bz2
Content-length: 238
http://gcc.gnu.org/bugzilla/show_bug.cgi?idW345
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
I think GCC is correct as it is processing the macros after they have been
redefined even though they are using #elif.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c/57345] Preprocessor fails to evaluation string token not valid
2013-05-20 22:10 [Bug c/57345] New: Preprocessor fails to evaluation string token not valid signupnathan at gmail dot com
@ 2013-05-20 22:38 ` jakub at gcc dot gnu.org
2013-05-20 22:39 ` jakub at gcc dot gnu.org
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: jakub at gcc dot gnu.org @ 2013-05-20 22:38 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57345
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
CC| |jakub at gcc dot gnu.org
Resolution|--- |FIXED
--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Dup.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c/57345] Preprocessor fails to evaluation string token not valid
2013-05-20 22:10 [Bug c/57345] New: Preprocessor fails to evaluation string token not valid signupnathan at gmail dot com
2013-05-20 22:38 ` [Bug c/57345] " jakub at gcc dot gnu.org
@ 2013-05-20 22:39 ` jakub at gcc dot gnu.org
2013-05-20 22:48 ` signupnathan at gmail dot com
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: jakub at gcc dot gnu.org @ 2013-05-20 22:39 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57345
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|FIXED |DUPLICATE
--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Dup of PR38161 I mean.
*** This bug has been marked as a duplicate of bug 38161 ***
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c/57345] Preprocessor fails to evaluation string token not valid
2013-05-20 22:10 [Bug c/57345] New: Preprocessor fails to evaluation string token not valid signupnathan at gmail dot com
2013-05-20 22:38 ` [Bug c/57345] " jakub at gcc dot gnu.org
2013-05-20 22:39 ` jakub at gcc dot gnu.org
@ 2013-05-20 22:48 ` signupnathan at gmail dot com
2013-05-20 22:52 ` pinskia at gcc dot gnu.org
2013-05-21 20:08 ` signupnathan at gmail dot com
4 siblings, 0 replies; 6+ messages in thread
From: signupnathan at gmail dot com @ 2013-05-20 22:48 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57345
signupnathan at gmail dot com changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|RESOLVED |UNCONFIRMED
Resolution|DUPLICATE |---
--- Comment #4 from signupnathan at gmail dot com ---
First, in this example, the first #if evaluates true, so I wouldn't think it
should even go on to evaluate the #endif and #else.
Secondly, this code fails as well:
#include <stdio.h>
int main (){
#if "foo" == "foo"
printf("foo matches");
#endif
return 0;
}
with this error:
/tmp/foo.c: In function ‘main’:
/tmp/foo.c:4:9: error: token ""foo"" is not valid in preprocessor expressions
It doesn't seem to be to be a duplicate as they were evaluating numericals.
This is evaluating strings.
>From gcc-bugs-return-422693-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Mon May 20 22:49:51 2013
Return-Path: <gcc-bugs-return-422693-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 6317 invoked by alias); 20 May 2013 22:49: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 6298 invoked by uid 48); 20 May 2013 22:49:48 -0000
From: "richard-gccbugzilla at metafoo dot co.uk" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/57346] New: g++ prematurely rejects references to local variables that are not odr-uses from local classes inside templates
Date: Mon, 20 May 2013 22:49:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: new
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: richard-gccbugzilla at metafoo dot co.uk
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: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter
Message-ID: <bug-57346-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: 2013-05/txt/msg01366.txt.bz2
Content-length: 763
http://gcc.gnu.org/bugzilla/show_bug.cgi?idW346
Bug ID: 57346
Summary: g++ prematurely rejects references to local variables
that are not odr-uses from local classes inside
templates
Product: gcc
Version: 4.9.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: richard-gccbugzilla at metafoo dot co.uk
g++ has a rejects-valid on this:
template<typename T> int f() {
T n = 0;
struct X { int get() { return n; } } x;
return x.get();
}
This template definition is valid: instantiation should succeed with T=const
int, for instance.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c/57345] Preprocessor fails to evaluation string token not valid
2013-05-20 22:10 [Bug c/57345] New: Preprocessor fails to evaluation string token not valid signupnathan at gmail dot com
` (2 preceding siblings ...)
2013-05-20 22:48 ` signupnathan at gmail dot com
@ 2013-05-20 22:52 ` pinskia at gcc dot gnu.org
2013-05-21 20:08 ` signupnathan at gmail dot com
4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu.org @ 2013-05-20 22:52 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57345
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution|--- |DUPLICATE
--- Comment #5 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to signupnathan from comment #4)
> It doesn't seem to be to be a duplicate as they were evaluating numericals.
> This is evaluating strings.
Evaluating strings is not a valid thing for the preprocessor.
*** This bug has been marked as a duplicate of bug 38161 ***
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c/57345] Preprocessor fails to evaluation string token not valid
2013-05-20 22:10 [Bug c/57345] New: Preprocessor fails to evaluation string token not valid signupnathan at gmail dot com
` (3 preceding siblings ...)
2013-05-20 22:52 ` pinskia at gcc dot gnu.org
@ 2013-05-21 20:08 ` signupnathan at gmail dot com
4 siblings, 0 replies; 6+ messages in thread
From: signupnathan at gmail dot com @ 2013-05-21 20:08 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57345
--- Comment #6 from signupnathan at gmail dot com ---
OK. Noted.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2013-05-21 20:08 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-05-20 22:10 [Bug c/57345] New: Preprocessor fails to evaluation string token not valid signupnathan at gmail dot com
2013-05-20 22:38 ` [Bug c/57345] " jakub at gcc dot gnu.org
2013-05-20 22:39 ` jakub at gcc dot gnu.org
2013-05-20 22:48 ` signupnathan at gmail dot com
2013-05-20 22:52 ` pinskia at gcc dot gnu.org
2013-05-21 20:08 ` signupnathan at gmail dot com
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).