public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/30857]  New: accepts both explicit instantiation and explicit specialization, duplicate explicit instantiations, etc.
@ 2007-02-19 11:19 bkoz at gcc dot gnu dot org
  2007-03-09  4:20 ` [Bug c++/30857] [4.1/4.2/4.3 regression] " bangerth at dealii dot org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: bkoz at gcc dot gnu dot org @ 2007-02-19 11:19 UTC (permalink / raw)
  To: gcc-bugs

I thought g++ used to warn for this:

template <typename T>
class foo { };

template<> class foo<int> { };

template class foo<int>;

Where the error was something informative like "one may not explicitly
specialize and explicitly instantiate" blah blah blah

However, mainline currently does not do this.

>From 14.7

-5- No program shall explicitly instantiate any template more than once, both
explicitly instantiate and explicitly specialize a template, or specialize a
template more than once for a given set of template-arguments. An
implementation is not required to diagnose a violation of this rule.

So, this is not required by the standard. As a QoI issue, however, this would
be  beneficial. 

Here's why I wanted this: if one is doing API testing, and the API requires
explicit specializations, than one possible negative test is to explicitly
instantiate the required specialization and get an error. 

Otherwise, I suppose another neg test is to redefine the specialization. This
is also not required to give an error, but current g++ does (redefinition
error). 

Note also, no diagnostic for duplicate explicit instantiations:

template <typename T>
class foo { };

template class foo<int>;
template class foo<int>;


Either of these or all may be a warning regressions (if my mind is not playing
tricks on me.)

I have not tested with other compilers, or previous g++ versions.

Consistent behavior for all three cases would be appreciated.


-- 
           Summary: accepts both explicit instantiation and explicit
                    specialization, duplicate explicit instantiations, etc.
           Product: gcc
           Version: 4.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: bkoz at gcc dot gnu dot org
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu


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


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

* [Bug c++/30857] [4.1/4.2/4.3 regression] accepts both explicit instantiation and explicit specialization, duplicate explicit instantiations, etc.
  2007-02-19 11:19 [Bug c++/30857] New: accepts both explicit instantiation and explicit specialization, duplicate explicit instantiations, etc bkoz at gcc dot gnu dot org
@ 2007-03-09  4:20 ` bangerth at dealii dot org
  2007-03-09 18:56 ` pinskia at gcc dot gnu dot org
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: bangerth at dealii dot org @ 2007-03-09  4:20 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from bangerth at dealii dot org  2007-03-09 04:20 -------
We got a warning in gcc2.95, but it has apparently already disappeared in
gcc3.2.x.

W.


-- 

bangerth at dealii dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bangerth at dealii dot org
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|0                           |1
           Keywords|                            |diagnostic
   Last reconfirmed|0000-00-00 00:00:00         |2007-03-09 04:20:37
               date|                            |
            Summary|accepts both explicit       |[4.1/4.2/4.3 regression]
                   |instantiation and explicit  |accepts both explicit
                   |specialization, duplicate   |instantiation and explicit
                   |explicit instantiations,    |specialization, duplicate
                   |etc.                        |explicit instantiations,
                   |                            |etc.


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


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

* [Bug c++/30857] [4.1/4.2/4.3 regression] accepts both explicit instantiation and explicit specialization, duplicate explicit instantiations, etc.
  2007-02-19 11:19 [Bug c++/30857] New: accepts both explicit instantiation and explicit specialization, duplicate explicit instantiations, etc bkoz at gcc dot gnu dot org
  2007-03-09  4:20 ` [Bug c++/30857] [4.1/4.2/4.3 regression] " bangerth at dealii dot org
@ 2007-03-09 18:56 ` pinskia at gcc dot gnu dot org
  2007-03-11 19:56 ` mmitchel at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2007-03-09 18:56 UTC (permalink / raw)
  To: gcc-bugs



-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |4.1.3


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


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

* [Bug c++/30857] [4.1/4.2/4.3 regression] accepts both explicit instantiation and explicit specialization, duplicate explicit instantiations, etc.
  2007-02-19 11:19 [Bug c++/30857] New: accepts both explicit instantiation and explicit specialization, duplicate explicit instantiations, etc bkoz at gcc dot gnu dot org
  2007-03-09  4:20 ` [Bug c++/30857] [4.1/4.2/4.3 regression] " bangerth at dealii dot org
  2007-03-09 18:56 ` pinskia at gcc dot gnu dot org
@ 2007-03-11 19:56 ` mmitchel at gcc dot gnu dot org
  2007-09-23 19:50 ` simartin at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: mmitchel at gcc dot gnu dot org @ 2007-03-11 19:56 UTC (permalink / raw)
  To: gcc-bugs



-- 

mmitchel at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P2


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


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

* [Bug c++/30857] [4.1/4.2/4.3 regression] accepts both explicit instantiation and explicit specialization, duplicate explicit instantiations, etc.
  2007-02-19 11:19 [Bug c++/30857] New: accepts both explicit instantiation and explicit specialization, duplicate explicit instantiations, etc bkoz at gcc dot gnu dot org
                   ` (2 preceding siblings ...)
  2007-03-11 19:56 ` mmitchel at gcc dot gnu dot org
@ 2007-09-23 19:50 ` simartin at gcc dot gnu dot org
  2008-01-24 17:19 ` pcarlini at suse dot de
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: simartin at gcc dot gnu dot org @ 2007-09-23 19:50 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from simartin at gcc dot gnu dot org  2007-09-23 19:49 -------
I've done tests with the current mainline and I wonder if this PR is still
"valid"...

We report an error for the following three cases:

1. Multiple specializations:
   template <typename T> class A {};
   template<> class A<int> {};
   template<> class A<int> {};

2. Multiple explicit instantiations:
   template <typename T> class B {};
   template class B<int>;
   template class B<int>;

3. Specialization following an explicit instantiation:
   template <typename T> class D {};
   template class D<int>;
   template<> class D<int> {};

The fact that we accept an explicit instantiation after a specialization is due
to DR 259.


-- 

simartin at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |simartin at gcc dot gnu dot
                   |                            |org


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


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

* [Bug c++/30857] [4.1/4.2/4.3 regression] accepts both explicit instantiation and explicit specialization, duplicate explicit instantiations, etc.
  2007-02-19 11:19 [Bug c++/30857] New: accepts both explicit instantiation and explicit specialization, duplicate explicit instantiations, etc bkoz at gcc dot gnu dot org
                   ` (3 preceding siblings ...)
  2007-09-23 19:50 ` simartin at gcc dot gnu dot org
@ 2008-01-24 17:19 ` pcarlini at suse dot de
  2008-01-24 17:26 ` bkoz at gcc dot gnu dot org
  2008-01-24 18:43 ` pcarlini at suse dot de
  6 siblings, 0 replies; 8+ messages in thread
From: pcarlini at suse dot de @ 2008-01-24 17:19 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from pcarlini at suse dot de  2008-01-24 16:42 -------
Benjamin, can you have a look to the resolution of DR 259:

  http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#259

I believe Simon is basically right...


-- 


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


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

* [Bug c++/30857] [4.1/4.2/4.3 regression] accepts both explicit instantiation and explicit specialization, duplicate explicit instantiations, etc.
  2007-02-19 11:19 [Bug c++/30857] New: accepts both explicit instantiation and explicit specialization, duplicate explicit instantiations, etc bkoz at gcc dot gnu dot org
                   ` (4 preceding siblings ...)
  2008-01-24 17:19 ` pcarlini at suse dot de
@ 2008-01-24 17:26 ` bkoz at gcc dot gnu dot org
  2008-01-24 18:43 ` pcarlini at suse dot de
  6 siblings, 0 replies; 8+ messages in thread
From: bkoz at gcc dot gnu dot org @ 2008-01-24 17:26 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from bkoz at gcc dot gnu dot org  2008-01-24 17:18 -------

I have verified that all three of simon's test cases now error on mainline, as
expected. Hurray!!! So, this can be closed as fixed, I guess.

Note 4.1.2 also errors, so maybe this was a result of some temporary
fluctuation in mainline.

I would like to make sure that Simon's test cases make it into the g++
testsuite, so that this doesn't reappear in the future. (But am unsure about
the state of g++ testsuite and don't want duplicates, so I defer.)


-- 


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


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

* [Bug c++/30857] [4.1/4.2/4.3 regression] accepts both explicit instantiation and explicit specialization, duplicate explicit instantiations, etc.
  2007-02-19 11:19 [Bug c++/30857] New: accepts both explicit instantiation and explicit specialization, duplicate explicit instantiations, etc bkoz at gcc dot gnu dot org
                   ` (5 preceding siblings ...)
  2008-01-24 17:26 ` bkoz at gcc dot gnu dot org
@ 2008-01-24 18:43 ` pcarlini at suse dot de
  6 siblings, 0 replies; 8+ messages in thread
From: pcarlini at suse dot de @ 2008-01-24 18:43 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from pcarlini at suse dot de  2008-01-24 17:36 -------
Excellent, indeed. I also checked stock 4.2.1 and current 4_2-branch.


-- 

pcarlini at suse dot de changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED


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


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

end of thread, other threads:[~2008-01-24 17:37 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-02-19 11:19 [Bug c++/30857] New: accepts both explicit instantiation and explicit specialization, duplicate explicit instantiations, etc bkoz at gcc dot gnu dot org
2007-03-09  4:20 ` [Bug c++/30857] [4.1/4.2/4.3 regression] " bangerth at dealii dot org
2007-03-09 18:56 ` pinskia at gcc dot gnu dot org
2007-03-11 19:56 ` mmitchel at gcc dot gnu dot org
2007-09-23 19:50 ` simartin at gcc dot gnu dot org
2008-01-24 17:19 ` pcarlini at suse dot de
2008-01-24 17:26 ` bkoz at gcc dot gnu dot org
2008-01-24 18:43 ` pcarlini at suse dot de

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