public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "public at alisdairm dot net" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/60605] New: incorrect diagosis of default template argument for function declaration inside class template member function
Date: Thu, 20 Mar 2014 22:04:00 -0000	[thread overview]
Message-ID: <bug-60605-4@http.gcc.gnu.org/bugzilla/> (raw)

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

            Bug ID: 60605
           Summary: incorrect diagosis of default template argument for
                    function declaration inside class template member
                    function
           Product: gcc
           Version: 4.8.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: public at alisdairm dot net

This bug looks looks obscure, but breaks our 'static assert' facility for C++03
compilers (after applying a workaround for the gcc 4.8 unused typedef warning):

template <typename T = int>
struct Foo {
    void bar() {
        void bug();
    }
};


This should simply be declaring 'bug' as a function in the enclosing namespace,
the default template parameter on the class template is irrelevant, 'bug' is
neither a function template nor a member function of a class template.

With g++ -std=c++03 I get:

main.cpp: In member function 'void Foo<T>::bar()':
main.cpp:4:18: error: default template arguments may not be used in function
templates without -std=c++11 or -std=gnu++11
         void bug();
                  ^

With g++ -std=c++11 I get:
main.cpp: In member function 'void Foo<T>::bar()':
main.cpp:4:18: error: default argument for template parameter for class
enclosing 'void bug()'
         void bug();
                  ^

I am not sure what language rule the C++11 switch thinks it is diagnosing, this
code is accepted by the Clang compiler which I used as a cross-check.


             reply	other threads:[~2014-03-20 22:04 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-20 22:04 public at alisdairm dot net [this message]
2014-06-17 23:04 ` [Bug c++/60605] " jason at gcc dot gnu.org
2014-06-17 23:09 ` jason at gcc dot gnu.org
2014-06-17 23:11 ` jason at gcc dot gnu.org
2014-06-17 23:11 ` 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-60605-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: link
Be 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).