This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/15745] New: exception specification incorrectly changes the type of the exception thrown


$ cat gccexceptionbug.cxx

#include <iostream>
using namespace std;

typedef int IntArray[10];

void test_array() throw (IntArray) {
//void test_array() {
    static IntArray arr;
    for (int i=0; i<10; i++) {
        arr[i] = i;
    }
    throw arr;
}

int main ()
{
    cout << "Start" << endl;

    try {
        test_array();
    } catch (IntArray) {
        cout << "Caught!" << endl;
    }

    cout << "Finish" << endl;

    return 0;
}


$ g++-3.4.0 -v -save-temps gccexceptionbug.cxx -o gccexceptionbug
Reading specs from /usr/lib/gcc/i586-mandrake-linux-gnu/3.4.0/specs
Configured with: ../configure --prefix=/usr --libdir=/usr/lib
--with-slibdir=/lib --mandir=/usr/share/man --infodir=/usr/share/info
--enable-shared --enable-threads=posix --disable-checking --enable-long-long
--enable-__cxa_atexit --enable-clocale=gnu --disable-libunwind-exceptions
--enable-languages=c,c++,java --program-suffix=-3.4.0
--host=i586-mandrake-linux-gnu --with-system-zlib
Thread model: posix
gcc version 3.4.0 (Mandrake Linux 10.0 3.4.0-1mdk)
 /usr/lib/gcc/i586-mandrake-linux-gnu/3.4.0/cc1plus -E -quiet -v -D_GNU_SOURCE
gccexceptionbug.cxx -mtune=pentium -o gccexceptionbug.ii
ignoring nonexistent directory
"/usr/lib/gcc/i586-mandrake-linux-gnu/3.4.0/../../../../i586-mandrake-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/lib/gcc/i586-mandrake-linux-gnu/3.4.0/../../../../include/c++/3.4.0
 /usr/lib/gcc/i586-mandrake-linux-gnu/3.4.0/../../../../include/c++/3.4.0/i586-mandrake-linux-gnu
 /usr/lib/gcc/i586-mandrake-linux-gnu/3.4.0/../../../../include/c++/3.4.0/backward
 /usr/local/include
 /usr/lib/gcc/i586-mandrake-linux-gnu/3.4.0/include
 /usr/include
End of search list.
 /usr/lib/gcc/i586-mandrake-linux-gnu/3.4.0/cc1plus -fpreprocessed
gccexceptionbug.ii -quiet -dumpbase gccexceptionbug.cxx -mtune=pentium -auxbase
gccexceptionbug -version -o gccexceptionbug.s
GNU C++ version 3.4.0 (Mandrake Linux 10.0 3.4.0-1mdk) (i586-mandrake-linux-gnu)
        compiled by GNU C version 3.4.0 (Mandrake Linux 10.0 3.4.0-1mdk).
GGC heuristics: --param ggc-min-expand=47 --param ggc-min-heapsize=32000
 as -V -Qy -o gccexceptionbug.o gccexceptionbug.s
GNU assembler version 2.14.90.0.5 (i586-mandrake-linux-gnu) using BFD version
2.14.90.0.5 20030722
 /usr/lib/gcc/i586-mandrake-linux-gnu/3.4.0/collect2 --eh-frame-hdr -m elf_i386
-dynamic-linker /lib/ld-linux.so.2 -o gccexceptionbug
/usr/lib/gcc/i586-mandrake-linux-gnu/3.4.0/../../../crt1.o
/usr/lib/gcc/i586-mandrake-linux-gnu/3.4.0/../../../crti.o
/usr/lib/gcc/i586-mandrake-linux-gnu/3.4.0/crtbegin.o
-L/usr/lib/gcc/i586-mandrake-linux-gnu/3.4.0
-L/usr/lib/gcc/i586-mandrake-linux-gnu/3.4.0
-L/usr/lib/gcc/i586-mandrake-linux-gnu/3.4.0/../../.. gccexceptionbug.o -lstdc++
-lm -lgcc_s -lgcc -lc -lgcc_s -lgcc
/usr/lib/gcc/i586-mandrake-linux-gnu/3.4.0/crtend.o
/usr/lib/gcc/i586-mandrake-linux-gnu/3.4.0/../../../crtn.o
$
$ ./gccexceptionbug
Start
terminate called after throwing an instance of 'int*'
Aborted
$


Note that if  the exception specification in the definition of test_array() is
removed, the exception is caught. (Replace with the commented out line). The
same behaviour was observed in gcc version 3.3.1 (cygming special).

-- 
           Summary: exception specification incorrectly changes the type of
                    the exception thrown
           Product: gcc
           Version: 3.4.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: wsf at fultondesigns dot co dot uk
                CC: gcc-bugs at gcc dot gnu dot org
  GCC host triplet: i586-mandrake-linux-gnu


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]