public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "raplonu.jb at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/111608] Cannot declare partial specialization after full specialization
Date: Fri, 29 Sep 2023 01:16:58 +0000	[thread overview]
Message-ID: <bug-111608-4-cAIgqsIzf5@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-111608-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #4 from Julien Bernard <raplonu.jb at gmail dot com> ---
(In reply to Jonathan Wakely from comment #3)

I wasn't sure how to describe this issue, so my last sentence was probably
incorrect.

> I suspect this is covered by [temp.point] p7:
> 
> "If two different points of instantiation give a template specialization
> different meanings according to the one-definition rule (6.3), the program
> is ill-formed, no diagnostic required."

If I take this example:

// 1. primary template
template<typename T>
struct X {
    int f() { return 1; }
};

// 2. partial template specialization 
template<typename T>
struct X<T*> {
    int f() {return 2; }
};

// 3. full template specialization
template<>
struct X<int*> {
    int f() { return 3; }
};

This program is well formed. In addition, the above 3. full template
specialization is equivalent to the following 4. implicit instantiation in the
sense they produce the same program (please, correct me if I'm wrong):

// 4. implicit instantiation
template<>
int X<int*>::f() { return 3; }

If I move 3. between 1. and 2., it still compiles but won't when 4. is between
1. and 2.

Here is a live demo with gcc, clang and msvc as a simple point of comparison.

https://godbolt.org/z/36aceTTb5

      parent reply	other threads:[~2023-09-29  1:17 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-27  8:22 [Bug c++/111608] New: " raplonu.jb at gmail dot com
2023-09-27  8:54 ` [Bug c++/111608] " rguenth at gcc dot gnu.org
2023-09-27 12:05 ` redi at gcc dot gnu.org
2023-09-27 12:09 ` redi at gcc dot gnu.org
2023-09-29  1:16 ` raplonu.jb at gmail dot com [this message]

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-111608-4-cAIgqsIzf5@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).