public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libgcc/60939] New: AIX: exceptions not caught when calling function via pointer
@ 2014-04-23 12:07 lbl2007 at gmx dot net
  2014-04-23 12:09 ` [Bug libgcc/60939] " lbl2007 at gmx dot net
                   ` (12 more replies)
  0 siblings, 13 replies; 14+ 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=60939

            Bug ID: 60939
           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] 14+ messages in thread

end of thread, other threads:[~2023-06-13 14:44 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-04-23 12:07 [Bug libgcc/60939] New: AIX: exceptions not caught when calling function via pointer lbl2007 at gmx dot net
2014-04-23 12:09 ` [Bug libgcc/60939] " lbl2007 at gmx dot net
2014-04-23 12:15 ` lbl2007 at gmx dot net
2014-04-26  0:35 ` dje at gcc dot gnu.org
2014-05-06 16:13 ` lbl2007 at gmx dot net
2014-05-08 15:01 ` dje at gcc dot gnu.org
2015-03-19 23:38 ` zoltan at hidvegi dot com
2015-03-21  5:59 ` dje at gcc dot gnu.org
2015-03-21  7:43 ` zoltan at hidvegi dot com
2015-03-21 21:11 ` dje at gcc dot gnu.org
2023-06-12 20:25 ` adam.swartz@ricoh-usa.com
2023-06-12 22:16 ` dje at gcc dot gnu.org
2023-06-13 14:39 ` adam.swartz@ricoh-usa.com
2023-06-13 14:44 ` adam.swartz@ricoh-usa.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).