[LLVMbugs] [Bug 9485] New: Exception specifications should only be instantiated when the function is
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Tue Mar 15 13:18:09 PDT 2011
http://llvm.org/bugs/show_bug.cgi?id=9485
Summary: Exception specifications should only be instantiated
when the function is
Product: clang
Version: trunk
Platform: PC
OS/Version: All
Status: NEW
Severity: normal
Priority: P
Component: C++
AssignedTo: unassignedclangbugs at nondot.org
ReportedBy: sebastian.redl at getdesigned.at
CC: llvmbugs at cs.uiuc.edu, dgregor at apple.com
Consider:
template <typename T>
void f1(T) throw(typename T::exception);
template <typename T>
void f1(T, int = 0) throw(typename T::noitpecxe);
template <typename T>
void f2(T) noexcept(T::throws);
template <typename T>
void f2(T, int = 0) noexcept(T::sworht);
void test() {
f1(0);
f2(0);
}
The above test case can distinguish between the treatment of exception
specifications during overload resolution and template instantiations. There
are three possible outcomes:
1) The program fails with an ambiguity error. This is what the standard says
should happen, because exception specifications are not part of the function
type and thus are not instantiated during overload resolution, only when
actually instantiating the function. So both templates are equally valid. This
is what Comeau Online does. (For the throw() spec. Comeau doesn't yet support
noexcept.)
2) The program fails with no available overloads. This is what would happen if
the exception specification were a SFINAE context. This also happens to be what
GCC 4.5 does. (Again, for throw(). I don't have handy access to GCC 4.6.)
3) The program generates errors when resolving the overloads, because int
cannot be used on the left side of ::. This is what happens when the compiler
instantiates the spec together with the type, but doesn't treat it as a SFINAE
context.
Clang first produces the error from 3, but then also produces the error from 1.
--
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
More information about the llvm-bugs
mailing list