From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8765 invoked by alias); 23 Mar 2012 16:57:19 -0000 Received: (qmail 8750 invoked by uid 22791); 23 Mar 2012 16:57:14 -0000 X-SWARE-Spam-Status: No, hits=-2.4 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from localhost (HELO gcc.gnu.org) (127.0.0.1) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 23 Mar 2012 16:56:27 +0000 From: "sir_nawaz959 at yahoo dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/52688] New: static local variable can accessed from local class of function template Date: Fri, 23 Mar 2012 17:20:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Keywords: X-Bugzilla-Severity: major X-Bugzilla-Who: sir_nawaz959 at yahoo dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Message-ID: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2012-03/txt/msg02055.txt.bz2 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 T f() { static const double staticLocalVariable = 100.0; struct local { static double f() { return staticLocalVariable; } }; return T(local::f()); } int main() { std::cout << f() << std::endl; } While gcc-4.5.1 compiles fine this code, gcc-4.6.1 gives error, saying: undefined reference to `staticLocalVariable'