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

            Bug ID: 60361
           Summary: unexpected 'use of parameter outside function body'
                    error
           Product: gcc
           Version: 4.9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: rogero at howzatt dot demon.co.uk

When declaring a variable with a bracketed constructor call, and using the same
external name for the first argument and a template instantiation used as the
second argument, the delaration can fail to compile.

----- registration.cpp -----
struct Helper
{
  Helper(int a, void (*pfunc)());
};

template <int I> void function();

const int A = 1;
const int B = 2;

Helper testOk(A, function<A>);

Helper testOk2(int(A), function<B>);

Helper testOk3((int(A)), function<A>);

// Why does (only) this one fail?
Helper testFail(int(A), function<A>);
----- ends -----

registration.cpp:18:34: error: use of parameter 'A' outside function body
 Helper testFail(int(A), function<A>);
                                  ^
registration.cpp:18:34: error: use of parameter 'A' outside function body
registration.cpp:18:34: error: use of parameter 'A' outside function body
registration.cpp:18:36: error: no matching function for call to
'Helper::Helper(int, <unresolved overloaded function type>)'
 Helper testFail(int(A), function<A>);
                                    ^
registration.cpp:18:36: note: candidates are:
registration.cpp:3:3: note: Helper::Helper(int, void (*)())
   Helper(int a, void (*pfunc)());
   ^
registration.cpp:3:3: note:   no known conversion for argument 2 from
'<unresolved overloaded function type>' to 'void (*)()'
registration.cpp:1:8: note: Helper::Helper(const Helper&)
 struct Helper
        ^
registration.cpp:1:8: note:   candidate expects 1 argument, 2 provided

----
Fails with g++ 4.9.0 and 4.8.1
Works with g++ 4.2.3, Clang 3.2, ICC 13.0 and MSVC 8 thru 12.

Reply via email to