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