public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/52688] New: static local variable can accessed from local class of function template
@ 2012-03-23 17:20 sir_nawaz959 at yahoo dot com
  2012-03-23 18:02 ` [Bug c++/52688] " giulianodammando at libero dot it
                   ` (12 more replies)
  0 siblings, 13 replies; 14+ messages in thread
From: sir_nawaz959 at yahoo dot com @ 2012-03-23 17:20 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52688

             Bug #: 52688
           Summary: static local variable can accessed from local class of
                    function template
    Classification: Unclassified
           Product: gcc
           Version: 4.6.1
            Status: UNCONFIRMED
          Severity: major
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: sir_nawaz959@yahoo.com


As per the C++ specification, static local variable can be accessed from local
class of function template, but GCC 4.6.1 gives error for the following
code-snippet:

template<typename T>
T f()
{
  static const double staticLocalVariable = 100.0;
  struct local
  {
      static double f() { return staticLocalVariable; }
  };
  return T(local::f());
}

int main() {
        std::cout << f<double>() << std::endl;
}

While gcc-4.5.1 compiles fine this code, gcc-4.6.1 gives error, saying:

undefined reference to `staticLocalVariable'


^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2013-03-02 11:18 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-03-23 17:20 [Bug c++/52688] New: static local variable can accessed from local class of function template sir_nawaz959 at yahoo dot com
2012-03-23 18:02 ` [Bug c++/52688] " giulianodammando at libero dot it
2012-03-24 15:20 ` redi at gcc dot gnu.org
2012-03-24 16:32 ` sir_nawaz959 at yahoo dot com
2012-03-25  4:27 ` redi at gcc dot gnu.org
2012-03-26 15:44 ` redi at gcc dot gnu.org
2012-03-26 15:56 ` sir_nawaz959 at yahoo dot com
2013-01-16  9:04 ` daniel.kruegler at googlemail dot com
2013-03-01 19:54 ` jared.cantwell at gmail dot com
2013-03-01 23:09 ` paolo.carlini at oracle dot com
2013-03-01 23:16 ` paolo.carlini at oracle dot com
2013-03-01 23:19 ` jared.cantwell at gmail dot com
2013-03-01 23:24 ` paolo.carlini at oracle dot com
2013-03-02 11:18 ` paolo at gcc dot gnu.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).