This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/52688] static local variable can accessed from local class of function template
- From: "sir_nawaz959 at yahoo dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Mon, 26 Mar 2012 15:54:46 +0000
- Subject: [Bug c++/52688] static local variable can accessed from local class of function template
- Auto-submitted: auto-generated
- References: <bug-52688-4@http.gcc.gnu.org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52688
--- Comment #6 from Sarfaraz Nawaz <sir_nawaz959 at yahoo dot com> 2012-03-26 15:54:46 UTC ---
(In reply to comment #5)
> (In reply to comment #0)
> > While gcc-4.5.1 compiles fine this code
>
> Are you sure? I get the same error with 4.1.2, 4.4.3, 4.5.2, 4.6.3 and 4.7.0
>
> 4.5.2 compiles and links OK with optimisation enabled, but so do the other
> versions
I used ideone.com to compile it, which uses gcc-4.5.1 with -std=c++0x.
http://ideone.com/Y2vIF
I just noticed that though it compiles and links fine, but it doesn't print the
expected output. :|
Interestingly, when I remove `const` from the definition of the static local
variable, and then I attempt to change it from the local class, it then gives
error:
http://ideone.com/vvwRc
:-)