This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug libstdc++/64241] New: make_exception_ptr returns garbage with -fno-exceptions
- From: "redi at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Tue, 09 Dec 2014 15:26:48 +0000
- Subject: [Bug libstdc++/64241] New: make_exception_ptr returns garbage with -fno-exceptions
- Auto-submitted: auto-generated
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64241
Bug ID: 64241
Summary: make_exception_ptr returns garbage with
-fno-exceptions
Product: gcc
Version: 5.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: libstdc++
Assignee: unassigned at gcc dot gnu.org
Reporter: redi at gcc dot gnu.org
#include <exception>
int main()
{
std::exception_ptr p = std::make_exception_ptr(1);
if (!p)
return 1;
}
g++ ex.cc -fno-exceptions -std=c++11 && valgrind ./a.out
==18255== Memcheck, a memory error detector
==18255== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
==18255== Using Valgrind-3.9.0 and LibVEX; rerun with -h for copyright info
==18255== Command: ./a.out
==18255==
==18255== Conditional jump or move depends on uninitialised value(s)
==18255== at 0x40066A: main (in /tmp/a.out)
==18255==
==18255== Conditional jump or move depends on uninitialised value(s)
==18255== at 0x394C85EB3A: std::__exception_ptr::exception_ptr::_M_release()
(eh_ptr.cc:86)
==18255== by 0x40068A: main (in /tmp/a.out)
==18255==
==18255== Use of uninitialised value of size 8
==18255== at 0x394C85EB3C: std::__exception_ptr::exception_ptr::_M_release()
(eh_ptr.cc:90)
==18255== by 0x40068A: main (in /tmp/a.out)
==18255==
==18255==
==18255== Process terminating with default action of signal 11 (SIGSEGV):
dumping core
==18255== Bad permissions for mapped region at address 0x400670
==18255== at 0x394C85EB3C: std::__exception_ptr::exception_ptr::_M_release()
(eh_ptr.cc:90)
==18255== by 0x40068A: main (in /tmp/a.out)
==18255==
==18255== HEAP SUMMARY:
==18255== in use at exit: 0 bytes in 0 blocks
==18255== total heap usage: 0 allocs, 0 frees, 0 bytes allocated
==18255==
==18255== All heap blocks were freed -- no leaks are possible
==18255==
==18255== For counts of detected and suppressed errors, rerun with: -v
==18255== Use --track-origins=yes to see where uninitialised values come from
==18255== ERROR SUMMARY: 3 errors from 3 contexts (suppressed: 2 from 2)
Segmentation fault
We don't return anything when exceptions are disabled:
template<typename _Ex>
exception_ptr
make_exception_ptr(_Ex __ex) _GLIBCXX_USE_NOEXCEPT
{
__try
{
#ifdef __EXCEPTIONS
throw __ex;
#endif
}
__catch(...)
{
return current_exception();
}
}
We should probably just return a default-constructed object.