[Bug c++/48581] New: [C++0x][SFINAE] Lack of ADL in default template argument types

daniel.kruegler at googlemail dot com gcc-bugzilla@gcc.gnu.org
Tue Apr 12 19:24:00 GMT 2011


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

           Summary: [C++0x][SFINAE] Lack of ADL in default template
                    argument types
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: daniel.kruegler@googlemail.com


gcc 4.7 in C++0x mode rejects the following program, but accepts it, when the
define USE_AS_RET_TYPE is activated by uncommenting:

--------------
template<class T>
T&& create();

//#define USE_AS_RET_TYPE

#ifndef USE_AS_RET_TYPE
template<class T,
 class = decltype(foo(create<T>()))
>
auto f(int) -> char;
#else
template<class T>
auto f(int) -> decltype(foo(create<T>()), char());
#endif

template<class>
auto f(...) -> char (&)[2];

struct S {};

void foo(S);

static_assert(sizeof(f<S>(0)) == 1, "Error"); // (#)

int main() {}
--------------

(#) "error: 'foo' was not declared in this scope"

Instantiation of the f(int) overload should properly honor ADL because of the
type-dependent expression as it does in the alternative form as part of the
return type.



More information about the Gcc-bugs mailing list