public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/27646] New: compiling very simple flex generated code results in global variabl error with GCC 4.0.1
@ 2006-05-17 19:03 jesser at pixelworks dot com
2006-05-17 19:06 ` [Bug c/27646] " pinskia at gcc dot gnu dot org
0 siblings, 1 reply; 2+ messages in thread
From: jesser at pixelworks dot com @ 2006-05-17 19:03 UTC (permalink / raw)
To: gcc-bugs
Hi,
My system is a macbook pro (intel duo core) with standard install of OS X. GCC
version 4.01 Build 5250.
I am writing a flex program and ran across a very strange issue. When building
and running the following flex (lex) program, the global variable access does
not work properly. The expected output from this program (when the a character
is found) is :
glo = 5
5 = ret, glo = 5
but when building/running this program using GCC 4.01 , I get this output:
glo = 5
5 = ret, glo = 0
It works well with GCC v3.x
Here is the simple lex program:
%{
#include <stdio.h>
#define yywrap() 1
int glo;
%}
%%
"a" { glo = 5;
printf("glo = %d\n", glo);
return (int)5;
}
%%
main ()
{
printf("%d = ret, glo = %d", yylex(), glo);
}
To build this, I am running:
flex test.l
gcc lex.yy.c
to run,
a.out
Then press the a key and enter.
--
Summary: compiling very simple flex generated code results in
global variabl error with GCC 4.0.1
Product: gcc
Version: 4.0.1
Status: UNCONFIRMED
Severity: critical
Priority: P3
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: jesser at pixelworks dot com
GCC build triplet: GCC version 4.0.1 build 5250
GCC host triplet: MacBookPro OSX
GCC target triplet: MacBookPro OSX i686-apple-darwin8
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27646
^ permalink raw reply [flat|nested] 2+ messages in thread
* [Bug c/27646] compiling very simple flex generated code results in global variabl error with GCC 4.0.1
2006-05-17 19:03 [Bug c/27646] New: compiling very simple flex generated code results in global variabl error with GCC 4.0.1 jesser at pixelworks dot com
@ 2006-05-17 19:06 ` pinskia at gcc dot gnu dot org
0 siblings, 0 replies; 2+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-05-17 19:06 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from pinskia at gcc dot gnu dot org 2006-05-17 19:06 -------
printf("%d = ret, glo = %d", yylex(), glo);
The C standard does not specify if yylex() or glo is evulated first.
So you are running into that effect and this is code undefined.
See PR 11751 for future reference.
*** This bug has been marked as a duplicate of 11751 ***
--
pinskia at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |DUPLICATE
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27646
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2006-05-17 19:06 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-05-17 19:03 [Bug c/27646] New: compiling very simple flex generated code results in global variabl error with GCC 4.0.1 jesser at pixelworks dot com
2006-05-17 19:06 ` [Bug c/27646] " pinskia at gcc dot gnu dot 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).