This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/38380] New: explicitly defaulted constructors vs. empty direct initialization
- From: "bkoz at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 3 Dec 2008 08:03:24 -0000
- Subject: [Bug c++/38380] New: explicitly defaulted constructors vs. empty direct initialization
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
Another C++0x default issue, with Last Changed Rev: 142359
// { dg-options "-std=gnu++0x" }
namespace std
{
struct atomic_bool
{
bool _M_i;
atomic_bool() = default;
~atomic_bool() = default;
atomic_bool(const atomic_bool&) = delete;
atomic_bool& operator=(const atomic_bool&) = delete;
atomic_bool(bool __i) { _M_i = __i; }
operator bool() const volatile
{ return true; }
};
}
namespace __gnu_test
{
struct direct_list_initializable
{
template<typename _Ttype, typename _Tvalue>
void
operator()()
{
struct _Concept
{
void __constraint()
{
_Ttype __v1 { }; // default ctor
_Ttype __v2 { __a }; // single-argument ctor
}
_Tvalue __a;
};
void (_Concept::*__x)() __attribute__((unused))
= &_Concept::__constraint;
}
};
}
int main()
{
__gnu_test::direct_list_initializable test;
test.operator()<std::atomic_bool, bool>();
return 0;
}
Gives:
%/mnt/share/bld/gcc/./gcc/g++ -shared-libgcc -B/mnt/share/bld/gcc/./gcc
-nostdinc++ -L/mnt/share/bld/gcc/x86_64-unknown-linux-gnu/libstdc++-v3/src
-L/mnt/share/bld/gcc/x86_64-unknown-linux-gnu/libstdc++-v3/src/.libs
-B/mnt/share/bld/H-x86-gcc/x86_64-unknown-linux-gnu/bin/
-B/mnt/share/bld/H-x86-gcc/x86_64-unknown-linux-gnu/lib/ -isystem
/mnt/share/bld/H-x86-gcc/x86_64-unknown-linux-gnu/include -isystem
/mnt/share/bld/H-x86-gcc/x86_64-unknown-linux-gnu/sys-include -g -O2
-D_GLIBCXX_ASSERT -fmessage-length=0 -ffunction-sections -fdata-sections -g -O2
-D_GNU_SOURCE -g -O2 -D_GNU_SOURCE -DLOCALEDIR="." -nostdinc++
-I/mnt/share/bld/gcc/x86_64-unknown-linux-gnu/libstdc++-v3/include/x86_64-unknown-linux-gnu
-I/mnt/share/bld/gcc/x86_64-unknown-linux-gnu/libstdc++-v3/include
-I/mnt/share/src/gcc/libstdc++-v3/libsupc++
-I/mnt/share/src/gcc/libstdc++-v3/include/backward
-I/mnt/share/src/gcc/libstdc++-v3/testsuite/util -Wl,--gc-sections
/mnt/share/src/gcc/libstdc++-v3/testsuite/29_atomics/atomic_integral/cons/direct_list_2.cc
-std=gnu++0x ./libtestc++.a -lm -o ./direct_list.exe -Wfatal-errors
/mnt/share/src/gcc/libstdc++-v3/testsuite/29_atomics/atomic_integral/cons/direct_list_2.cc:
In member function 'void
__gnu_test::direct_list_initializable::operator()()::_Concept::__constraint()
[with _Ttype = std::atomic_bool, _Tvalue = bool]':
/mnt/share/src/gcc/libstdc++-v3/testsuite/29_atomics/atomic_integral/cons/direct_list_2.cc:76:
instantiated from 'void __gnu_test::direct_list_initializable::operator()()
[with _Ttype = std::atomic_bool, _Tvalue = bool]'
/mnt/share/src/gcc/libstdc++-v3/testsuite/29_atomics/atomic_integral/cons/direct_list_2.cc:86:
instantiated from here
/mnt/share/src/gcc/libstdc++-v3/testsuite/29_atomics/atomic_integral/cons/direct_list_2.cc:68:
error: converting to 'const std::atomic_bool' from initializer list would use
explicit constructor 'std::atomic_bool::atomic_bool()'
compilation terminated due to -Wfatal-errors.
It's the "would use explicit constructor" bits that are confusing, since there
is only an explicitly defaulted constructor.
Also, this message should say something about using the default constructor to
create the members of the initialization list.
--
Summary: explicitly defaulted constructors vs. empty direct
initialization
Product: gcc
Version: 4.4.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: jason at gcc dot gnu dot org
ReportedBy: bkoz at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38380