public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/64241] New: make_exception_ptr returns garbage with -fno-exceptions
@ 2014-12-09 15:26 redi at gcc dot gnu.org
  2014-12-12 15:10 ` [Bug libstdc++/64241] " redi at gcc dot gnu.org
  2014-12-12 16:09 ` redi at gcc dot gnu.org
  0 siblings, 2 replies; 3+ messages in thread
From: redi at gcc dot gnu.org @ 2014-12-09 15:26 UTC (permalink / raw)
  To: gcc-bugs

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.


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

end of thread, other threads:[~2014-12-12 16:09 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-12-09 15:26 [Bug libstdc++/64241] New: make_exception_ptr returns garbage with -fno-exceptions redi at gcc dot gnu.org
2014-12-12 15:10 ` [Bug libstdc++/64241] " redi at gcc dot gnu.org
2014-12-12 16:09 ` redi at gcc dot gnu.org

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).