public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/56480] New: Explicit specialization in a namespace enclosing the specialized template
@ 2013-02-28  8:18 zeratul976 at hotmail dot com
  2013-03-05  1:29 ` [Bug c++/56480] " redi at gcc dot gnu.org
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: zeratul976 at hotmail dot com @ 2013-02-28  8:18 UTC (permalink / raw)
  To: gcc-bugs


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

             Bug #: 56480
           Summary: Explicit specialization in a namespace enclosing the
                    specialized template
    Classification: Unclassified
           Product: gcc
           Version: 4.8.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: zeratul976@hotmail.com


The following code:


namespace Foo 
{
    template <typename T>
    struct Meow
    {
    };
}

template <>
struct Foo::Meow<int>
{
};


fails to compile with gcc 4.8 (tested with 20130224 snapshot). 

I believe this code should be accepted in C++11 mode as per [temp.expl.spec]
p2: "An explicit specialization shall be declared in a namespace enclosing the
specialized template." This is a relaxation of the C++03 wording: "An explicit
specialization shall be declared in the namespace of which the template is a
member".

Recent versions of clang and MSVC compile the above code in C++11 mode.


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

* [Bug c++/56480] Explicit specialization in a namespace enclosing the specialized template
  2013-02-28  8:18 [Bug c++/56480] New: Explicit specialization in a namespace enclosing the specialized template zeratul976 at hotmail dot com
@ 2013-03-05  1:29 ` redi at gcc dot gnu.org
  2013-03-05  4:30 ` zeratul976 at hotmail dot com
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: redi at gcc dot gnu.org @ 2013-03-05  1:29 UTC (permalink / raw)
  To: gcc-bugs


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

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2013-03-05
     Ever Confirmed|0                           |1

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> 2013-03-05 01:29:27 UTC ---
I think this is
http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#374


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

* [Bug c++/56480] Explicit specialization in a namespace enclosing the specialized template
  2013-02-28  8:18 [Bug c++/56480] New: Explicit specialization in a namespace enclosing the specialized template zeratul976 at hotmail dot com
  2013-03-05  1:29 ` [Bug c++/56480] " redi at gcc dot gnu.org
@ 2013-03-05  4:30 ` zeratul976 at hotmail dot com
  2013-11-29 23:49 ` lichray at gmail dot com
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: zeratul976 at hotmail dot com @ 2013-03-05  4:30 UTC (permalink / raw)
  To: gcc-bugs


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

--- Comment #2 from Nathan Ridge <zeratul976 at hotmail dot com> 2013-03-05 04:30:26 UTC ---
(In reply to comment #1)
> I think this is
> http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#374

Ah, I see. The code is accepted if a declaration (without definition) of the
specialization is placed in the namespace. Didn't realize that.


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

* [Bug c++/56480] Explicit specialization in a namespace enclosing the specialized template
  2013-02-28  8:18 [Bug c++/56480] New: Explicit specialization in a namespace enclosing the specialized template zeratul976 at hotmail dot com
  2013-03-05  1:29 ` [Bug c++/56480] " redi at gcc dot gnu.org
  2013-03-05  4:30 ` zeratul976 at hotmail dot com
@ 2013-11-29 23:49 ` lichray at gmail dot com
  2014-11-01 15:51 ` trippels at gcc dot gnu.org
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: lichray at gmail dot com @ 2013-11-29 23:49 UTC (permalink / raw)
  To: gcc-bugs

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

Zhihao Yuan <lichray at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |lichray at gmail dot com

--- Comment #3 from Zhihao Yuan <lichray at gmail dot com> ---
(In reply to Nathan Ridge from comment #2)
> (In reply to comment #1)
> > I think this is
> > http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#374
> 
> Ah, I see. The code is accepted if a declaration (without definition) of the
> specialization is placed in the namespace. Didn't realize that.

?? That was the c++03 status, and the new wording ("or to a specialization
thereof") relaxed this requirement.

Has this been implemented?


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

* [Bug c++/56480] Explicit specialization in a namespace enclosing the specialized template
  2013-02-28  8:18 [Bug c++/56480] New: Explicit specialization in a namespace enclosing the specialized template zeratul976 at hotmail dot com
                   ` (2 preceding siblings ...)
  2013-11-29 23:49 ` lichray at gmail dot com
@ 2014-11-01 15:51 ` trippels at gcc dot gnu.org
  2014-11-01 18:05 ` trippels at gcc dot gnu.org
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: trippels at gcc dot gnu.org @ 2014-11-01 15:51 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56480

Markus Trippelsdorf <trippels at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |trippels at gcc dot gnu.org

--- Comment #4 from Markus Trippelsdorf <trippels at gcc dot gnu.org> ---
*** Bug 63705 has been marked as a duplicate of this bug. ***


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

* [Bug c++/56480] Explicit specialization in a namespace enclosing the specialized template
  2013-02-28  8:18 [Bug c++/56480] New: Explicit specialization in a namespace enclosing the specialized template zeratul976 at hotmail dot com
                   ` (3 preceding siblings ...)
  2014-11-01 15:51 ` trippels at gcc dot gnu.org
@ 2014-11-01 18:05 ` trippels at gcc dot gnu.org
  2014-11-02 11:48 ` trippels at gcc dot gnu.org
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: trippels at gcc dot gnu.org @ 2014-11-01 18:05 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56480

Markus Trippelsdorf <trippels at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |rejects-valid
                 CC|                            |jason at gcc dot gnu.org

--- Comment #5 from Markus Trippelsdorf <trippels at gcc dot gnu.org> ---
Two possible fixes: 

1)
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 2cf10f442f68..09a545496fa8 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -785,8 +785,12 @@ check_specialization_namespace (tree tmpl)
     return true;
   else
     {
-      permerror (input_location, "specialization of %qD in different
namespace", tmpl);
-      permerror (input_location, "  from definition of %q+#D", tmpl);
+      if (cxx_dialect < cxx11)
+       {
+         permerror (input_location, "specialization of %qD in different "
+                    "namespace", tmpl);
+         permerror (input_location, "  from definition of %q+#D", tmpl);
+       }
       return false;
     }
 }

2)
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 2cf10f442f68..1171b5d736d5 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -780,15 +780,15 @@ check_specialization_namespace (tree tmpl)
       error ("specialization of %qD must appear at namespace scope", tmpl);
       return false;
     }
-  if (is_associated_namespace (current_namespace, tpl_ns))
-    /* Same or super-using namespace.  */
-    return true;
-  else
+  if (!is_associated_namespace (current_namespace, tpl_ns) &&
+      (cxx_dialect < cxx11))
     {
       permerror (input_location, "specialization of %qD in different
namespace", tmpl);
       permerror (input_location, "  from definition of %q+#D", tmpl);
       return false;
     }
+
+  return true;
 }

 /* SPEC is an explicit instantiation.  Check that it is valid to


The following testcases:

g++.dg/template/spec17.C
g++.dg/template/spec25.C
g++.dg/template/spec36.C
g++.old-deja/g++.ns/template13.C
g++.old-deja/g++.pt/explicit73.C 
g++.old-deja/g++.pt/lookup10.C

would have to be updated.


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

* [Bug c++/56480] Explicit specialization in a namespace enclosing the specialized template
  2013-02-28  8:18 [Bug c++/56480] New: Explicit specialization in a namespace enclosing the specialized template zeratul976 at hotmail dot com
                   ` (4 preceding siblings ...)
  2014-11-01 18:05 ` trippels at gcc dot gnu.org
@ 2014-11-02 11:48 ` trippels at gcc dot gnu.org
  2015-04-22 12:06 ` jakub at gcc dot gnu.org
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: trippels at gcc dot gnu.org @ 2014-11-02 11:48 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56480

Markus Trippelsdorf <trippels at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Assignee|unassigned at gcc dot gnu.org      |trippels at gcc dot gnu.org
   Target Milestone|---                         |5.0


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

* [Bug c++/56480] Explicit specialization in a namespace enclosing the specialized template
  2013-02-28  8:18 [Bug c++/56480] New: Explicit specialization in a namespace enclosing the specialized template zeratul976 at hotmail dot com
                   ` (5 preceding siblings ...)
  2014-11-02 11:48 ` trippels at gcc dot gnu.org
@ 2015-04-22 12:06 ` jakub at gcc dot gnu.org
  2015-07-16  9:13 ` rguenth at gcc dot gnu.org
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: jakub at gcc dot gnu.org @ 2015-04-22 12:06 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56480

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|5.0                         |5.2

--- Comment #6 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
GCC 5.1 has been released.


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

* [Bug c++/56480] Explicit specialization in a namespace enclosing the specialized template
  2013-02-28  8:18 [Bug c++/56480] New: Explicit specialization in a namespace enclosing the specialized template zeratul976 at hotmail dot com
                   ` (6 preceding siblings ...)
  2015-04-22 12:06 ` jakub at gcc dot gnu.org
@ 2015-07-16  9:13 ` rguenth at gcc dot gnu.org
  2021-08-04 20:42 ` pinskia at gcc dot gnu.org
  2021-08-23  8:33 ` pinskia at gcc dot gnu.org
  9 siblings, 0 replies; 11+ messages in thread
From: rguenth at gcc dot gnu.org @ 2015-07-16  9:13 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56480

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|5.2                         |5.3

--- Comment #7 from Richard Biener <rguenth at gcc dot gnu.org> ---
GCC 5.2 is being released, adjusting target milestone to 5.3.


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

* [Bug c++/56480] Explicit specialization in a namespace enclosing the specialized template
  2013-02-28  8:18 [Bug c++/56480] New: Explicit specialization in a namespace enclosing the specialized template zeratul976 at hotmail dot com
                   ` (7 preceding siblings ...)
  2015-07-16  9:13 ` rguenth at gcc dot gnu.org
@ 2021-08-04 20:42 ` pinskia at gcc dot gnu.org
  2021-08-23  8:33 ` pinskia at gcc dot gnu.org
  9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-08-04 20:42 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56480

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |redi at gcc dot gnu.org

--- Comment #13 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
*** Bug 60786 has been marked as a duplicate of this bug. ***

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

* [Bug c++/56480] Explicit specialization in a namespace enclosing the specialized template
  2013-02-28  8:18 [Bug c++/56480] New: Explicit specialization in a namespace enclosing the specialized template zeratul976 at hotmail dot com
                   ` (8 preceding siblings ...)
  2021-08-04 20:42 ` pinskia at gcc dot gnu.org
@ 2021-08-23  8:33 ` pinskia at gcc dot gnu.org
  9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-08-23  8:33 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56480

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |Simon.Richter at hogyros dot de

--- Comment #14 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
*** Bug 42018 has been marked as a duplicate of this bug. ***

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

end of thread, other threads:[~2021-08-23  8:33 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-02-28  8:18 [Bug c++/56480] New: Explicit specialization in a namespace enclosing the specialized template zeratul976 at hotmail dot com
2013-03-05  1:29 ` [Bug c++/56480] " redi at gcc dot gnu.org
2013-03-05  4:30 ` zeratul976 at hotmail dot com
2013-11-29 23:49 ` lichray at gmail dot com
2014-11-01 15:51 ` trippels at gcc dot gnu.org
2014-11-01 18:05 ` trippels at gcc dot gnu.org
2014-11-02 11:48 ` trippels at gcc dot gnu.org
2015-04-22 12:06 ` jakub at gcc dot gnu.org
2015-07-16  9:13 ` rguenth at gcc dot gnu.org
2021-08-04 20:42 ` pinskia at gcc dot gnu.org
2021-08-23  8:33 ` pinskia 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).