From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10032 invoked by alias); 9 Dec 2014 15:26:55 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 10002 invoked by uid 48); 9 Dec 2014 15:26:50 -0000 From: "redi at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/64241] New: make_exception_ptr returns garbage with -fno-exceptions Date: Tue, 09 Dec 2014 15:26:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: libstdc++ X-Bugzilla-Version: 5.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: redi at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2014-12/txt/msg00923.txt.bz2 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 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 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.