[Bug c++/56633] New: Overload selection error for non-static data member initialization with initializer list in template class

st at quanttec dot com gcc-bugzilla@gcc.gnu.org
Sat Mar 16 13:26:00 GMT 2013


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

             Bug #: 56633
           Summary: Overload selection error for non-static data member
                    initialization with initializer list in template class
    Classification: Unclassified
           Product: gcc
           Version: 4.8.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: st@quanttec.com


g++ (the current SVN version) fails to compile the following valid c++11 code

#include <atomic>

struct Test1 {
    std::atomic<int> value2{0}; // no problem here
};

template <typename T> // T is not used
struct Test2 {
    std::atomic<int> value2{0}; // fails to compile
};

int main() {
    Test1 test;
    Test2<int> test2;
    return 0;
}

The following error message is generated for Test2:

g++ --std=c++11 test.cpp
test.cpp: In constructor ‘constexpr Test2<int>::Test2()’:
test.cpp:8:8: error: use of deleted function ‘std::atomic<int>::atomic(const
std::atomic<int>&)’
 struct Test2 {
        ^
In file included from test.cpp:1:0:
/opt/gcc/include/c++/4.8.0/atomic:601:7: error: declared here
       atomic(const atomic&) = delete;
       ^
test.cpp: In function ‘int main()’:
test.cpp:14:16: note: synthesized method ‘constexpr Test2<int>::Test2()’ first
required here 
     Test2<int> test2;



More information about the Gcc-bugs mailing list