Bug 47956 - [C++0x] gcc accepts static data member declaration with initializer for non-const literal type if type-specifier is auto
Summary: [C++0x] gcc accepts static data member declaration with initializer for non-c...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.6.0
: P3 normal
Target Milestone: 4.7.0
Assignee: Jason Merrill
URL:
Keywords: accepts-invalid
Depends on:
Blocks:
 
Reported: 2011-03-02 13:53 UTC by Ryou Ezoe
Modified: 2011-05-27 04:38 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2011-03-02 17:18:22


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ryou Ezoe 2011-03-02 13:53:22 UTC
gcc accepts static data member declaration with brace-or-equal-initializer for non-const literal type, when the type-specifier is the plain auto specifier.

struct X
{
    static auto member = 0 ;
} ;

The type of X::member is deduced to be int.
But static data member declaration is allowed to have brace-or-equal-initializer if the type is const literal type.

So this code must be ill-formed.
Comment 1 Jonathan Wakely 2011-03-02 17:18:22 UTC
confirmed, not a regression
Comment 2 Jason Merrill 2011-05-27 04:01:51 UTC
Author: jason
Date: Fri May 27 04:01:46 2011
New Revision: 174317

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=174317
Log:
	PR c++/47956
	* decl.c (check_static_variable_definition): Now static.
	(cp_finish_decl): Call it here.
	(grokdeclarator): Not here.
	* pt.c (instantiate_class_template_1): Or here.
	* cp-tree.h: Don't declare it.

Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/cp-tree.h
    trunk/gcc/cp/decl.c
    trunk/gcc/cp/pt.c
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/g++.dg/cpp0x/auto7.C
    trunk/gcc/testsuite/g++.dg/template/crash50.C
    trunk/gcc/testsuite/g++.dg/template/static9.C
    trunk/gcc/testsuite/g++.old-deja/g++.ext/memconst.C
Comment 3 Jason Merrill 2011-05-27 04:38:32 UTC
Fixed for 4.7.0.