public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/23823] New: Is this right?
@ 2005-09-11 13:34 igodard at pacbell dot net
  2005-09-11 14:46 ` [Bug c++/23823] " pinskia at gcc dot gnu dot org
                   ` (10 more replies)
  0 siblings, 11 replies; 13+ messages in thread
From: igodard at pacbell dot net @ 2005-09-11 13:34 UTC (permalink / raw)
  To: gcc-bugs

struct foo {
    template<bool b>
    void    f();
    template<typename T, bool b>
    void    g();
    };

template<>
void    foo::f<true>() {}
template<>
void    foo::f<false>() {}
template<typename T>
void    foo::g<T, true>() {}
template<typename T>
void    foo::g<T, false>() {}


gets you:

~/ootbc/members/src$ g++ foo.cc
foo.cc:13: error: partial specialization `g<T, true>' of function template
foo.cc:13: error: got 1 template parameters for `void foo::g()'
foo.cc:13: error:   but 2 required
foo.cc:15: error: partial specialization `g<T,  false>' of function template
foo.cc:15: error: redefinition of `void foo::g()'
foo.cc:13: error: `void foo::g()' previously declared here
foo.cc:15: error: got 1 template parameters for `void foo::g()'
foo.cc:15: error:   but 2 required


The error message is hosed, because there are in fact two parameters. Not sure
whether the code is valid or not (but it should be :-)

-- 
           Summary: Is this right?
           Product: gcc
           Version: 3.4.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: igodard at pacbell dot net
                CC: gcc-bugs at gcc dot gnu dot org


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


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

* [Bug c++/23823] Is this right?
  2005-09-11 13:34 [Bug c++/23823] New: Is this right? igodard at pacbell dot net
@ 2005-09-11 14:46 ` pinskia at gcc dot gnu dot org
  2005-09-11 15:45 ` igodard at pacbell dot net
                   ` (9 subsequent siblings)
  10 siblings, 0 replies; 13+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-09-11 14:46 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-09-11 14:46 -------
(In reply to comment #0)
> foo.cc:13: error: partial specialization `g<T, true>' of function template
> foo.cc:13: error: got 1 template parameters for `void foo::g()'
> foo.cc:13: error:   but 2 required

No, there are only one:
template<typename T>

-- 


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


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

* [Bug c++/23823] Is this right?
  2005-09-11 13:34 [Bug c++/23823] New: Is this right? igodard at pacbell dot net
  2005-09-11 14:46 ` [Bug c++/23823] " pinskia at gcc dot gnu dot org
@ 2005-09-11 15:45 ` igodard at pacbell dot net
  2005-09-11 23:40 ` bangerth at dealii dot org
                   ` (8 subsequent siblings)
  10 siblings, 0 replies; 13+ messages in thread
From: igodard at pacbell dot net @ 2005-09-11 15:45 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From igodard at pacbell dot net  2005-09-11 15:44 -------
Nah, tried:

struct foo {
    template<bool b>
    void    f();
    template<typename T, bool b>
    void    g();
    };

template<>
void    foo::f<true>() {}
template<>
void    foo::f<false>() {}
template<typename T, bool b>
void    foo::g<T, true>() {}
template<typename T, bool b>
void    foo::g<T, false>() {}


which gets me:

~/ootbc/members/src$ g++ foo.cc
foo.cc:13: error: partial specialization `g<T, true>' of function template
foo.cc:15: error: partial specialization `g<T,  false>' of function template
foo.cc:15: error: redefinition of `void foo::g()'
foo.cc:13: error: `void foo::g()' previously declared here
~/ootbc/members/src$ fg




-- 


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


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

* [Bug c++/23823] Is this right?
  2005-09-11 13:34 [Bug c++/23823] New: Is this right? igodard at pacbell dot net
  2005-09-11 14:46 ` [Bug c++/23823] " pinskia at gcc dot gnu dot org
  2005-09-11 15:45 ` igodard at pacbell dot net
@ 2005-09-11 23:40 ` bangerth at dealii dot org
  2005-09-12  1:15 ` igodard at pacbell dot net
                   ` (7 subsequent siblings)
  10 siblings, 0 replies; 13+ messages in thread
From: bangerth at dealii dot org @ 2005-09-11 23:40 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From bangerth at dealii dot org  2005-09-11 23:38 -------
The code is illegal (you can only partially specialize class templates, 
not function templates). I think the error message is clear: you only 
give one template parameter (and try, illegally, to fix the other), 
instead of having two template parameters as required (note the function 
has two parameters, but in your attempt of a partial specialization, you 
only leave one as a template while fixing the other to a particular value). 
 
W. 

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


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


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

* [Bug c++/23823] Is this right?
  2005-09-11 13:34 [Bug c++/23823] New: Is this right? igodard at pacbell dot net
                   ` (2 preceding siblings ...)
  2005-09-11 23:40 ` bangerth at dealii dot org
@ 2005-09-12  1:15 ` igodard at pacbell dot net
  2005-09-12  1:56 ` bangerth at dealii dot org
                   ` (6 subsequent siblings)
  10 siblings, 0 replies; 13+ messages in thread
From: igodard at pacbell dot net @ 2005-09-12  1:15 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From igodard at pacbell dot net  2005-09-12 01:14 -------
Well, you may think it's clear but I am am counter-example :-)  Perhaps
"template parameter" (in the message) is a formal term in the language syntax
specification (who but acompiler maven would know that?), but I expected that
"template parameter" refered to the template parameters, not the template
argument specifications. That is, I thought (in the example) that it referred to
"T, true" in "void    foo::g<T, true>() {}", rather than to "template<typename T>".

That is, you know what the message means only if you already know what it means,
which is by definition a bad diagnostic.

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


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


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

* [Bug c++/23823] Is this right?
  2005-09-11 13:34 [Bug c++/23823] New: Is this right? igodard at pacbell dot net
                   ` (3 preceding siblings ...)
  2005-09-12  1:15 ` igodard at pacbell dot net
@ 2005-09-12  1:56 ` bangerth at dealii dot org
  2005-09-12  3:17 ` igodard at pacbell dot net
                   ` (5 subsequent siblings)
  10 siblings, 0 replies; 13+ messages in thread
From: bangerth at dealii dot org @ 2005-09-12  1:56 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From bangerth at dealii dot org  2005-09-12 01:55 -------
Well, but then tell me what you expect for the case you have:  
  template<typename T>  
  void    foo::g<T, true>() {}  
How many template parameters do you give? I count one (in the   
'template <...>' angle brackets). And how many are expected (the  
language says it would be 2)?. Propose a better wording for the  
message, rather than just complaining about the existing text.  
  
W.  

-- 


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


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

* [Bug c++/23823] Is this right?
  2005-09-11 13:34 [Bug c++/23823] New: Is this right? igodard at pacbell dot net
                   ` (4 preceding siblings ...)
  2005-09-12  1:56 ` bangerth at dealii dot org
@ 2005-09-12  3:17 ` igodard at pacbell dot net
  2005-09-12  8:15 ` rguenth at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  10 siblings, 0 replies; 13+ messages in thread
From: igodard at pacbell dot net @ 2005-09-12  3:17 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From igodard at pacbell dot net  2005-09-12 03:17 -------
In the case you give I count one template argument specificatiob, and two
template parameters.

As for a better message, how about: "A template definition must have same number
of formal template specifications (within "template<...>") as the definition;
the actual arguments (within "name<...>") may differ."

Ivan

-- 


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


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

* [Bug c++/23823] Is this right?
  2005-09-11 13:34 [Bug c++/23823] New: Is this right? igodard at pacbell dot net
                   ` (5 preceding siblings ...)
  2005-09-12  3:17 ` igodard at pacbell dot net
@ 2005-09-12  8:15 ` rguenth at gcc dot gnu dot org
  2005-09-12 12:42 ` neil at daikokuya dot co dot uk
                   ` (3 subsequent siblings)
  10 siblings, 0 replies; 13+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2005-09-12  8:15 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From rguenth at gcc dot gnu dot org  2005-09-12 08:15 -------
It could say, instead of

foo.cc:13: error: partial specialization `g<T, true>' of function template

rather

foo.cc:13: error: partial specialization `g<T, true>' of function template not
allowed

to make it clear that the following errors are just other ways of saying the above.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |diagnostic


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


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

* [Bug c++/23823] Is this right?
  2005-09-11 13:34 [Bug c++/23823] New: Is this right? igodard at pacbell dot net
                   ` (6 preceding siblings ...)
  2005-09-12  8:15 ` rguenth at gcc dot gnu dot org
@ 2005-09-12 12:42 ` neil at daikokuya dot co dot uk
  2005-09-12 12:49 ` igodard at pacbell dot net
                   ` (2 subsequent siblings)
  10 siblings, 0 replies; 13+ messages in thread
From: neil at daikokuya dot co dot uk @ 2005-09-12 12:42 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From neil at daikokuya dot co dot uk  2005-09-12 12:42 -------
Subject: Re:  Is this right?

igodard at pacbell dot net wrote:-

> 
> ------- Additional Comments From igodard at pacbell dot net  2005-09-12 03:17 -------
> In the case you give I count one template argument specificatiob, and two
> template parameters.

Your understanding of the meaning of "parameter" and "argument" is
backwards, which is probably the source of your confusion.

Neil.


-- 


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


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

* [Bug c++/23823] Is this right?
  2005-09-11 13:34 [Bug c++/23823] New: Is this right? igodard at pacbell dot net
                   ` (7 preceding siblings ...)
  2005-09-12 12:42 ` neil at daikokuya dot co dot uk
@ 2005-09-12 12:49 ` igodard at pacbell dot net
  2005-09-12 14:54 ` bangerth at dealii dot org
  2005-09-12 15:39 ` gdr at integrable-solutions dot net
  10 siblings, 0 replies; 13+ messages in thread
From: igodard at pacbell dot net @ 2005-09-12 12:49 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From igodard at pacbell dot net  2005-09-12 12:48 -------
Neil -

Backwards no doubt! I'm sure that any programmer who has studied the formal
syntax of C++ will have it correctly forwards. For the remaining 99.95% of
programmers (who like me tend to use "parameter" and "argument" somewhat
interchangably) a little help in the diagnostic would be a welcome blessing.

Of course, if the target audience for gcc is the developers that work on it,
then the present message is just fine...

Ivan

-- 


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


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

* [Bug c++/23823] Is this right?
  2005-09-11 13:34 [Bug c++/23823] New: Is this right? igodard at pacbell dot net
                   ` (8 preceding siblings ...)
  2005-09-12 12:49 ` igodard at pacbell dot net
@ 2005-09-12 14:54 ` bangerth at dealii dot org
  2005-09-12 15:39 ` gdr at integrable-solutions dot net
  10 siblings, 0 replies; 13+ messages in thread
From: bangerth at dealii dot org @ 2005-09-12 14:54 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From bangerth at dealii dot org  2005-09-12 14:54 -------
(In reply to comment #9) 
 
> Of course, if the target audience for gcc is the developers that work on it, 
> then the present message is just fine... 
 
Well, it certainly isn't. We are just struggling with trying to find wordings 
that are understandable for the laypeople while still trying to be concise 
in notation, i.e. using the terminology of the standard. In addition, error 
messages need to be short. 
 
I, too, use argument and parameter interchangeably in colloquial speaking, 
but I believe that we should not do that in error messages. 
 
That said, I think Richard's suggestion in comment #7 goes in the right 
direction. 
 
W. 

-- 


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


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

* [Bug c++/23823] Is this right?
  2005-09-11 13:34 [Bug c++/23823] New: Is this right? igodard at pacbell dot net
                   ` (9 preceding siblings ...)
  2005-09-12 14:54 ` bangerth at dealii dot org
@ 2005-09-12 15:39 ` gdr at integrable-solutions dot net
  10 siblings, 0 replies; 13+ messages in thread
From: gdr at integrable-solutions dot net @ 2005-09-12 15:39 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From gdr at integrable-solutions dot net  2005-09-12 15:39 -------
Subject: Re:  Is this right?

"bangerth at dealii dot org" <gcc-bugzilla@gcc.gnu.org> writes:

| That said, I think Richard's suggestion in comment #7 goes in the right 
| direction. 

Indeed.  I would approve a patch implementating that suggestion.

-- Gaby


-- 


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


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

* [Bug c++/23823] Is this right?
       [not found] <bug-23823-6594@http.gcc.gnu.org/bugzilla/>
@ 2005-11-24  2:36 ` gdr at gcc dot gnu dot org
  0 siblings, 0 replies; 13+ messages in thread
From: gdr at gcc dot gnu dot org @ 2005-11-24  2:36 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #12 from gdr at gcc dot gnu dot org  2005-11-24 02:35 -------
Mainline already has Richard's suggestion.
Closing.


-- 

gdr at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |FIXED
   Target Milestone|---                         |4.2.0


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


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

end of thread, other threads:[~2005-11-24  2:36 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-09-11 13:34 [Bug c++/23823] New: Is this right? igodard at pacbell dot net
2005-09-11 14:46 ` [Bug c++/23823] " pinskia at gcc dot gnu dot org
2005-09-11 15:45 ` igodard at pacbell dot net
2005-09-11 23:40 ` bangerth at dealii dot org
2005-09-12  1:15 ` igodard at pacbell dot net
2005-09-12  1:56 ` bangerth at dealii dot org
2005-09-12  3:17 ` igodard at pacbell dot net
2005-09-12  8:15 ` rguenth at gcc dot gnu dot org
2005-09-12 12:42 ` neil at daikokuya dot co dot uk
2005-09-12 12:49 ` igodard at pacbell dot net
2005-09-12 14:54 ` bangerth at dealii dot org
2005-09-12 15:39 ` gdr at integrable-solutions dot net
     [not found] <bug-23823-6594@http.gcc.gnu.org/bugzilla/>
2005-11-24  2:36 ` gdr at gcc dot gnu 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).