[Bug c++/47861] static variables inside member functions
michal.t at tiscali dot it
gcc-bugzilla@gcc.gnu.org
Thu Feb 24 13:13:00 GMT 2011
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47861
--- Comment #12 from Michal Turlik <michal.t at tiscali dot it> 2011-02-24 11:48:10 UTC ---
Yep the Meyer singleton!
T* instance()
{
static T instance;
return
&instance;
}
The trouble probably comes from this one...where the
static definition comes from?
Redi...I only tried to explain my point
of view...you and the rest of the bugzilla team know what to do.
Thank
you all so much!
----Messaggio originale----
Da: gcc-bugzilla@gcc.
gnu.org
Data: 24/02/2011 12.27
A: <michal.t@tiscali.it>
Ogg: [Bug
c++/47861] static variables inside member functions
http://gcc.gnu.
org/bugzilla/show_bug.cgi?id=47861
--- Comment #11 from Jonathan
Wakely <redi at gcc dot gnu.org> 2011-02-24 11:27:51 UTC ---
(In reply
to comment #10)
>
> oo.cc:4:3: Warning: 'it' is declared as a function-
scope
> static, error prone, see static member variables
No, it is
not "error prone" - it is valid C++, and even relied on by well-known
idioms such as the "Meyers Singleton"
Warning about it would be
annoying and unhelpful.
> Honestly this would
> be prevent if the
compiler was going to search for the static var
> definition.
I don't
understand this sentence, sorry.
More information about the Gcc-bugs
mailing list