This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/36870] New: __has_nothrow_constructor violates the ODR


The programs below detect an ODR violation in the libstdc++ implementation
of std::has_nothrow_default_constructor and the __has_nothrow_constructor
built-in compiler trait (hence I'm filing this as a bug in the c++ front
end rather than libstdc++).

$    cat u.cpp \
  && g++ -c -std=gnu++0x -o 1.o u.cpp \
  && g++ -DMAIN -std=gnu++0x u.cpp 1.o \
  && ./a.out
#include <cassert>
#include <type_traits>

struct S { S (); };

bool f ();

#ifdef MAIN

int main ()
{
    assert (std::has_nothrow_default_constructor<S>::value == f ());
}

#else
S::S () { }
bool f () { return std::has_nothrow_default_constructor<S>::value; }
#endif
a.out: u.cpp:12: int main(): Assertion
`std::has_nothrow_default_constructor<S>::value == f ()' failed.
Aborted


$ cat u.cpp && g++ -c -std=gnu++0x u.cpp && ./a.out
#include <cassert>

struct S { S (); };

bool f ();

int main ()
{
    assert (__has_nothrow_constructor (S) == f ());
}

S::S () { }

bool f () { return __has_nothrow_constructor (S); }
a.out: u.cpp:12: int main(): Assertion
`std::has_nothrow_default_constructor<S>::value == f ()' failed.
Aborted


-- 
           Summary: __has_nothrow_constructor violates the ODR
           Product: gcc
           Version: 4.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: sebor at roguewave dot com


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]