RE: Questions before submitting a bug report

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




> -----Original Message-----
> From: gcc-help-owner@xxxxxxxxxxx [mailto:gcc-help-owner@xxxxxxxxxxx] On
> Behalf Of Andrew Haley
> Sent: Dienstag, 3. Januar 2012 16:06
> To: gcc-help@xxxxxxxxxxx
> Subject: Re: Questions before submitting a bug report
> 
> On 01/03/2012 03:02 PM, Markus Henschel wrote:
> > struct Foo * foo_instance()
> > {
> > 	static struct Foo foo;
> > 	return &foo;
> > }
> 
> Uh, no.  You can't return a reference to a local variable.
> 
> Andrew.

But it's a static variable. Its lifetime extends across the runtime of the whole program. I'm not 100% sure for C but at least in C++ this is a well known pattern for singletons.



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux