public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/50370] New: [C++0x] Multiple declarations with default template arguments accepted
@ 2011-09-12 22:34 daniel.kruegler at googlemail dot com
  2012-01-28  6:28 ` [Bug c++/50370] " pinskia at gcc dot gnu.org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: daniel.kruegler at googlemail dot com @ 2011-09-12 22:34 UTC (permalink / raw)
  To: gcc-bugs

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

             Bug #: 50370
           Summary: [C++0x] Multiple declarations with default template
                    arguments accepted
    Classification: Unclassified
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: daniel.kruegler@googlemail.com
                CC: jason@redhat.com


gcc 4.7.0 20110903 (experimental) in C++0x mode accepts the following code:

template<class T, class = int>
void foo(T);

template<class T, class = int>
void foo(T) {}

template<class = int>
void bar();

template<class = int>
void bar() {}

int main() {
  foo(12);
  bar();
}

According to 14.1 [temp.param] p12 this code should be rejected:

"A template-parameter shall not be given default arguments by two different
declarations in the same scope. [ Example:
  template<class T = int> class X;
  template<class T = int> class X { /*... */ }; // error
—end example ]"

gcc correctly rejects such examples when class templates are involved, but
fails to do so for function templates. 

This looks very similar to bug 15339 or bug 48372, but the domain (default
template arguments) is different.


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2022-03-09 13:50 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-09-12 22:34 [Bug c++/50370] New: [C++0x] Multiple declarations with default template arguments accepted daniel.kruegler at googlemail dot com
2012-01-28  6:28 ` [Bug c++/50370] " pinskia at gcc dot gnu.org
2013-09-16 14:34 ` jwillemsen at remedy dot nl
2020-07-16 17:07 ` mpolacek at gcc dot gnu.org
2020-07-16 17:29 ` mpolacek at gcc dot gnu.org
2022-03-09 13:50 ` ppalka at gcc dot gnu.org

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).