[Bug c++/49027] New: g++ ignores -fno-exceptions in uninstantiated template
ian at airs dot com
gcc-bugzilla@gcc.gnu.org
Tue May 17 17:17:00 GMT 2011
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49027
Summary: g++ ignores -fno-exceptions in uninstantiated template
Product: gcc
Version: 4.7.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: ian@airs.com
This file compiles without error when using -fno-exceptions:
extern int f2();
template<typename T>
void f1() {
try { f2(); } catch (...) { }
}
Compiling this very similar file:
extern int f2();
template<typename T>
void f1() {
try { f2(); } catch (...) { }
}
template f1<int>();
gives these errors:
foo.cc: In function ‘void f1() [with T = int]’:
foo.cc:6: instantiated from here
foo.cc:4: error: exception handling disabled, use -fexceptions to enable
I think it would be more consistent for g++ to reject uses of try/catch when
compiling with -fno-exceptions even in uninstantiated templates. Otherwise you
can get surprising results when code changes: you can find problems in very
different pieces of code.
More information about the Gcc-bugs
mailing list