public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libgcc/60938] New: AIX: exceptions not caught when calling function via pointer
@ 2014-04-23 12:07 lbl2007 at gmx dot net
  2014-04-23 12:15 ` [Bug libgcc/60938] " lbl2007 at gmx dot net
  0 siblings, 1 reply; 2+ messages in thread
From: lbl2007 at gmx dot net @ 2014-04-23 12:07 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 60938
           Summary: AIX: exceptions not caught when calling function via
                    pointer
           Product: gcc
           Version: 4.8.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libgcc
          Assignee: unassigned at gcc dot gnu.org
          Reporter: lbl2007 at gmx dot net

The attached test program throws a std::runtime_error, but the corresponding
catch block is not executed. This only happens under certain circumstances. 
After some testing I found that the following conditions make the error appear:

(1) The function foo() doing the try/catch is in a compilation unit 
    different from main().
(2) foo() is called from main() via a function pointer (pfoo).
(3) pfoo is initialized in a global static constructor in a compilation 
    unit different from main.

To reproduce the error:
  g++ -g -o demo a.cc b.cc
  ./demo
  BEGIN
  terminate called after throwing an instance of 'std::runtime_error'
    what():  TILT
  IOT/Abort trap (core dumped)

Test program (both raw and preprocessed sources are in the attached TAR file):

//////////////////////////////////////////////////// FILE a.cc
#include <stdio.h>
#include <stdexcept>

extern void (*pFoo)();

void foo()
{
   fputs("BEGIN\n",stderr);
   try { throw std::runtime_error("TILT"); }
   catch( const std::runtime_error &e ) { }
   fputs("OK\n",stderr);
}

struct Init { Init() { pFoo = foo; } } init;

//////////////////////////////////////////////////// FILE b.cc
extern void foo();

void (*pFoo)() = 0;

int main( int argc, char *argv[] )
{
   pFoo();
   return 0;
}

//////////////////////////////////////////////////// Version info:
g++ -v
Using built-in specs.
COLLECT_GCC=/common/mringe/gcc482/local/bin/g++
COLLECT_LTO_WRAPPER=/common/mringe/gcc482/local/libexec/gcc/powerpc-ibm-aix6.1.0.0/4.8.2/lto-wrapper
Target: powerpc-ibm-aix6.1.0.0
Configured with: /common/mringe/gcc482/gcc-4.8.2/configure
--prefix=/common/mringe/gcc482/local --with-as=/usr/bin/as
--with-ld=/usr/bin/ld --enable-languages=c,c++
--enable-version-specific-runtime-libs --disable-nls --enable-decimal-float=dpd
--with-gmp=/common/mringe/gcc482/local --with-mpfr=/common/mringe/gcc482/local
--with-mpc=/common/mringe/gcc482/local
--with-local-prefix=/common/mringe/gcc482/local
Thread model: aix
gcc version 4.8.2 (GCC) 

uname -a
AIX srva001 1 6 00F817FA4C00 AIX


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

* [Bug libgcc/60938] AIX: exceptions not caught when calling function via pointer
  2014-04-23 12:07 [Bug libgcc/60938] New: AIX: exceptions not caught when calling function via pointer lbl2007 at gmx dot net
@ 2014-04-23 12:15 ` lbl2007 at gmx dot net
  0 siblings, 0 replies; 2+ messages in thread
From: lbl2007 at gmx dot net @ 2014-04-23 12:15 UTC (permalink / raw)
  To: gcc-bugs

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

lbl2007 at gmx dot net changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|---                         |DUPLICATE

--- Comment #1 from lbl2007 at gmx dot net ---
Duplicate, please delete

*** This bug has been marked as a duplicate of bug 60939 ***


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

end of thread, other threads:[~2014-04-23 12:15 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-04-23 12:07 [Bug libgcc/60938] New: AIX: exceptions not caught when calling function via pointer lbl2007 at gmx dot net
2014-04-23 12:15 ` [Bug libgcc/60938] " lbl2007 at gmx dot net

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