public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
From: corey taylor <corey.taylor@gmail.com>
To: Eljay Love-Jensen <eljay@adobe.com>
Cc: Thomas Neumann <tneumann@users.sourceforge.net>, gcc-help@gcc.gnu.org
Subject: Re: template specializiation
Date: Thu, 07 Jul 2005 15:25:00 -0000	[thread overview]
Message-ID: <2e393d0805070708244eab1d94@mail.gmail.com> (raw)
In-Reply-To: <6.2.1.2.2.20050707085151.025778e0@iplan-mn.corp.adobe.com>

This information from the ISO 14882 spec might help understand:

14.7.3.6

If a template, a member template or the member of a class template is
explicitly specialized then that specialization
shall be declared before the first use of that specialization that
would cause an implicit instantiation
to take place, in every translation unit in which such a use occurs;
no diagnostic is required. If the program
does not provide a definition for an explicit specialization and
either the specialization is used in a
way that would cause an implicit instantiation to take place or the
member is a virtual member function, the
program is ill-formed, no diagnostic required. An implicit
instantiation is never generated for an explicit
specialization that is declared but not defined. [Example:
template<class T> class Array { /* ... */ };
template<class T> void sort(Array<T>& v) { /* ... */ }
void f(Array<String>& v)
{
sort(v); //use primary template
// sort(Array<T>&), T is String
}
template<> void sort<String>(Array<String>& v); // error: specialization
// after use of primary template
template<> void sort<>(Array<char*>& v); // OK: sort<char*> not yet used
—end example]

corey

On 7/7/05, Eljay Love-Jensen <eljay@adobe.com> wrote:
> Hi Thomas,
> 
> Hmmm, unusual situation (for me).
> 
> Using...
> http://www.comeaucomputing.com/tryitout/
> 
> I tend to trust (EDG's front end) Comeau C++'s error message (strict mode, -tused) on this one.
> 
> How to unravel this riddle, I'm not sure.  Sorry.
> 
> --Eljay
> 
> - - - - -
> struct A
> {
>   const A* a;
> };
> 
> template <const char* c>
> struct B
> {
>   static const A b;
> };
> 
> extern const char c[1]="";
> extern const char d[1]="";
> 
> template<>
> const A B<c>::b =
> {
>   &B<d>::b
> };
> template<>
> const A B<d>::b = // Line 21
> {
>   &B<c>::b
> };
> - - - - -
> 
> Comeau C/C++ 4.3.3 (Aug  6 2003 15:13:37) for ONLINE_EVALUATION_BETA1
> Copyright 1988-2003 Comeau Computing.  All rights reserved.
> MODE:strict errors C++
> 
> "ComeauTest.c", line 21: error: explicit specialization of member
>           "B<c>::b [with c=d]" must precede its first use
>   const A B<d>::b =
>                 ^
> 
> "ComeauTest.c", line 24: warning: parsing restarts here after previous syntax error
>   };
>    ^
> 
> 1 error detected in the compilation of "ComeauTest.c".
> 
> 
>

  reply	other threads:[~2005-07-07 15:25 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-07-07 13:42 Thomas Neumann
2005-07-07 14:46 ` Eljay Love-Jensen
2005-07-07 15:25   ` corey taylor [this message]
2005-07-07 15:51     ` Thomas Neumann
2005-07-07 15:56       ` corey taylor
     [not found]         ` <42CD567F.2090702@users.sourceforge.net>
2005-07-07 16:39           ` corey taylor
2005-07-07 19:34             ` Thomas Neumann
2005-07-07 16:39           ` corey taylor

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=2e393d0805070708244eab1d94@mail.gmail.com \
    --to=corey.taylor@gmail.com \
    --cc=eljay@adobe.com \
    --cc=gcc-help@gcc.gnu.org \
    --cc=tneumann@users.sourceforge.net \
    /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).