public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/36870]  New: __has_nothrow_constructor violates the ODR
@ 2008-07-18 19:50 sebor at roguewave dot com
  2008-07-18 20:59 ` [Bug c++/36870] " pinskia at gcc dot gnu dot org
                   ` (13 more replies)
  0 siblings, 14 replies; 15+ messages in thread
From: sebor at roguewave dot com @ 2008-07-18 19:50 UTC (permalink / raw)
  To: gcc-bugs

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


^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2008-07-21  9:11 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-07-18 19:50 [Bug c++/36870] New: __has_nothrow_constructor violates the ODR sebor at roguewave dot com
2008-07-18 20:59 ` [Bug c++/36870] " pinskia at gcc dot gnu dot org
2008-07-18 21:11 ` paolo dot carlini at oracle dot com
2008-07-18 21:18 ` pinskia at gcc dot gnu dot org
2008-07-18 21:32 ` paolo dot carlini at oracle dot com
2008-07-18 21:48 ` sebor at roguewave dot com
2008-07-18 21:57 ` paolo dot carlini at oracle dot com
2008-07-18 22:12 ` sebor at roguewave dot com
2008-07-18 22:14 ` paolo dot carlini at oracle dot com
2008-07-18 22:18 ` paolo dot carlini at oracle dot com
2008-07-18 22:32 ` paolo dot carlini at oracle dot com
2008-07-18 22:53 ` mmitchel at gcc dot gnu dot org
2008-07-19  0:29 ` paolo dot carlini at oracle dot com
2008-07-21  9:10 ` paolo at gcc dot gnu dot org
2008-07-21  9:11 ` paolo dot carlini at oracle dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).