public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "rogero at howzatt dot demon.co.uk" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/60361] New: unexpected 'use of parameter outside function body' error Date: Thu, 27 Feb 2014 22:53:00 -0000 [thread overview] Message-ID: <bug-60361-4@http.gcc.gnu.org/bugzilla/> (raw) 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.
next reply other threads:[~2014-02-27 22:53 UTC|newest] Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top 2014-02-27 22:53 rogero at howzatt dot demon.co.uk [this message] 2014-03-03 9:49 ` [Bug c++/60361] [4.7/4.8/4.9 Regression] " redi at gcc dot gnu.org 2014-03-03 20:42 ` jason at gcc dot gnu.org 2014-03-05 17:54 ` jason at gcc dot gnu.org 2014-03-05 17:56 ` [Bug c++/60361] [4.7/4.8 " jason at gcc dot gnu.org 2014-06-12 13:49 ` rguenth at gcc dot gnu.org 2014-08-01 18:34 ` [Bug c++/60361] [4.8 " jason at gcc dot gnu.org
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-60361-4@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).