public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/37066]  New: partial specialization of function depends on the order
@ 2008-08-09 13:01 marc dot glisse at normalesup dot org
  2008-08-10  7:32 ` [Bug c++/37066] " pinskia at gcc dot gnu dot org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: marc dot glisse at normalesup dot org @ 2008-08-09 13:01 UTC (permalink / raw)
  To: gcc-bugs

In the following code, adapted from gmpxx, the output is HELLO2. If however I
change the order of the two partial specializations, the output becomes HELLO1.
At least one other compiler I tried outputs HELLO1 in both cases. I know that I
can remove the "template<>" and overload the function instead of partially
specializing it, but I would like to understand why the current code is
failing.


#include <iostream>

struct mpz_t{};

template <class T, class U>
class __gmp_expr{};

template <class T, class U>
void __gmp_set_expr(const __gmp_expr<T, U> &);

typedef __gmp_expr<mpz_t, mpz_t> mpz_class;

template <>
void __gmp_set_expr(const __gmp_expr<mpz_t, mpz_t> &expr)
{
    std::cerr << "HELLO1\n";
}

template <class T>
void __gmp_set_expr(const __gmp_expr<mpz_t, T> &expr)
{
    std::cerr << "HELLO2\n";
}

int main(){
    mpz_class a;
    mpz_t t;
    __gmp_set_expr(a);
}


-- 
           Summary: partial specialization of function depends on the order
           Product: gcc
           Version: 4.3.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: marc dot glisse at normalesup dot org
  GCC host triplet: i486-linux-gnu


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


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

* [Bug c++/37066] partial specialization of function depends on the order
  2008-08-09 13:01 [Bug c++/37066] New: partial specialization of function depends on the order marc dot glisse at normalesup dot org
@ 2008-08-10  7:32 ` pinskia at gcc dot gnu dot org
  2008-08-10  9:44 ` marc dot glisse at normalesup dot org
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2008-08-10  7:32 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from pinskia at gcc dot gnu dot org  2008-08-10 07:31 -------
Hmm, the one that says HELLO1 is fully specialization and not a partial one.  


-- 


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


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

* [Bug c++/37066] partial specialization of function depends on the order
  2008-08-09 13:01 [Bug c++/37066] New: partial specialization of function depends on the order marc dot glisse at normalesup dot org
  2008-08-10  7:32 ` [Bug c++/37066] " pinskia at gcc dot gnu dot org
@ 2008-08-10  9:44 ` marc dot glisse at normalesup dot org
  2008-08-10 10:51 ` marc dot glisse at normalesup dot org
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: marc dot glisse at normalesup dot org @ 2008-08-10  9:44 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from marc dot glisse at normalesup dot org  2008-08-10 09:42 -------
(In reply to comment #1)
> Hmm, the one that says HELLO1 is fully specialization and not a partial one.

Indeed, sorry for the wrong vocabulary. So the title should be something like:
partial specialization overrides earlier full specialization.


-- 


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


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

* [Bug c++/37066] partial specialization of function depends on the order
  2008-08-09 13:01 [Bug c++/37066] New: partial specialization of function depends on the order marc dot glisse at normalesup dot org
  2008-08-10  7:32 ` [Bug c++/37066] " pinskia at gcc dot gnu dot org
  2008-08-10  9:44 ` marc dot glisse at normalesup dot org
@ 2008-08-10 10:51 ` marc dot glisse at normalesup dot org
  2008-08-10 14:21 ` marc dot glisse at normalesup dot org
  2008-11-12 16:21 ` marc dot glisse at normalesup dot org
  4 siblings, 0 replies; 6+ messages in thread
From: marc dot glisse at normalesup dot org @ 2008-08-10 10:51 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from marc dot glisse at normalesup dot org  2008-08-10 10:50 -------
Hmm apparently partial specialization of function does not exist. Depending on
the order, the full specialization is considered either as a specialization of
the first declaration or of the HELLO2 one. Now the question is whether the
existence of a full specialization of the first declaration should give it
priority over an overload (that is more specific than the declaration but less
than the specialization).

I'll need to look at the standard for the answer (if someone knows it...).


-- 


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


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

* [Bug c++/37066] partial specialization of function depends on the order
  2008-08-09 13:01 [Bug c++/37066] New: partial specialization of function depends on the order marc dot glisse at normalesup dot org
                   ` (2 preceding siblings ...)
  2008-08-10 10:51 ` marc dot glisse at normalesup dot org
@ 2008-08-10 14:21 ` marc dot glisse at normalesup dot org
  2008-11-12 16:21 ` marc dot glisse at normalesup dot org
  4 siblings, 0 replies; 6+ messages in thread
From: marc dot glisse at normalesup dot org @ 2008-08-10 14:21 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from marc dot glisse at normalesup dot org  2008-08-10 14:20 -------
This looks really close to the exemple explained here (near the end):
http://www.gotw.ca/publications/mill17.htm

except that there is no <> or <...> after the name of the function in the
specialization (guess it is implicit).

So it looks like this is not a g++ bug. Sorry for the noise. If you agree with
this, please close the bug, I'll see about reporting the bug to the other
compiler and getting gmpxx fixed.


-- 


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


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

* [Bug c++/37066] partial specialization of function depends on the order
  2008-08-09 13:01 [Bug c++/37066] New: partial specialization of function depends on the order marc dot glisse at normalesup dot org
                   ` (3 preceding siblings ...)
  2008-08-10 14:21 ` marc dot glisse at normalesup dot org
@ 2008-11-12 16:21 ` marc dot glisse at normalesup dot org
  4 siblings, 0 replies; 6+ messages in thread
From: marc dot glisse at normalesup dot org @ 2008-11-12 16:21 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from marc dot glisse at normalesup dot org  2008-11-12 16:19 -------
This is not a bug (see previous comments).


-- 

marc dot glisse at normalesup dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |INVALID


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


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

end of thread, other threads:[~2008-11-12 16:21 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-08-09 13:01 [Bug c++/37066] New: partial specialization of function depends on the order marc dot glisse at normalesup dot org
2008-08-10  7:32 ` [Bug c++/37066] " pinskia at gcc dot gnu dot org
2008-08-10  9:44 ` marc dot glisse at normalesup dot org
2008-08-10 10:51 ` marc dot glisse at normalesup dot org
2008-08-10 14:21 ` marc dot glisse at normalesup dot org
2008-11-12 16:21 ` marc dot glisse at normalesup dot 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).