public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* Re: c++/7686: template compilation failure on unused method
@ 2002-08-22 16:56 Gabriel Dos Reis
  0 siblings, 0 replies; 6+ messages in thread
From: Gabriel Dos Reis @ 2002-08-22 16:56 UTC (permalink / raw)
  To: nobody; +Cc: gcc-prs

The following reply was made to PR c++/7686; it has been noted by GNATS.

From: Gabriel Dos Reis <gdr@integrable-solutions.net>
To: leick.robinson@motorola.com
Cc: gcc-gnats@gcc.gnu.org
Subject: Re: c++/7686: template compilation failure on unused method
Date: 23 Aug 2002 01:15:10 +0200

 leick.robinson@motorola.com writes:
 
 | This assumes that the rule for an uninstantiated member 
 | function extends to its declaration.  I am not certain
 | whether the C++ standard is clear on this point.
 
 You're right:  This is a bug in g++, it should have instantiated the
 *declarations* of the member functions.  I'll mark it as a regression.
 
 Thanks,
 
 -- Gaby


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

* Re: c++/7686: template compilation failure on unused method
@ 2002-10-16 10:21 mmitchel
  0 siblings, 0 replies; 6+ messages in thread
From: mmitchel @ 2002-10-16 10:21 UTC (permalink / raw)
  To: gcc-bugs, gcc-prs, leick.robinson, nobody

Synopsis: template compilation failure on unused method

State-Changed-From-To: analyzed->closed
State-Changed-By: mmitchel
State-Changed-When: Wed Oct 16 10:21:34 2002
State-Changed-Why:
    Not a bug.
    
    This code is invald, and is rightly rejected by GCC.

http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=7686


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

* Re: c++/7686: template compilation failure on unused method
@ 2002-08-23  9:36 Gabriel Dos Reis
  0 siblings, 0 replies; 6+ messages in thread
From: Gabriel Dos Reis @ 2002-08-23  9:36 UTC (permalink / raw)
  To: nobody; +Cc: gcc-prs

The following reply was made to PR c++/7686; it has been noted by GNATS.

From: Gabriel Dos Reis <gdr@integrable-solutions.net>
To: leick.robinson@motorola.com
Cc: gcc-gnats@gcc.gnu.org
Subject: Re: c++/7686: template compilation failure on unused method
Date: 23 Aug 2002 17:34:45 +0200

 Leick Robinson <leick.robinson@motorola.com> writes:
 
 | Do you mean that it was a bug in 2.95.2, that it should have instantiated
 | the declarations (and thus, failed to compile)?
 
 Yes.
 
 | And, further, that 3.0.4 is correct in its failure to compile?
 
 Yes.  The relevant chapter and verse is 14.7.1/1
 
   [...] The implicit instantiation of a class template specialization
   causes the implicit instantiation of the declarations, but not of
   the definitions or default arguments, of the class member
   func-tions, member classes, static data members and member
   templates; and it causes the implicit instantiation of the
   definitions of member anonymous unions. [...]
 
 | I'm not sure what a "regression from gcc-3.0.4" means (as stated in the
 | Audit Trail).
 
 I meant "GCC-3.0.4 got it right but now we get it wrong".
 
 -- Gaby


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

* Re: c++/7686: template compilation failure on unused method
@ 2002-08-23  8:46 Leick Robinson
  0 siblings, 0 replies; 6+ messages in thread
From: Leick Robinson @ 2002-08-23  8:46 UTC (permalink / raw)
  To: nobody; +Cc: gcc-prs

The following reply was made to PR c++/7686; it has been noted by GNATS.

From: Leick Robinson <leick.robinson@motorola.com>
To: Gabriel Dos Reis <gdr@integrable-solutions.net>
Cc: gcc-gnats@gcc.gnu.org
Subject: Re: c++/7686: template compilation failure on unused method
Date: Fri, 23 Aug 2002 10:17:33 -0500

 --------------71CDC3598563AC3C410BB7D1
 Content-Type: text/plain; charset=us-ascii
 Content-Transfer-Encoding: 7bit
 
 Gabriel,
 
 I'm not sure I fully understand your response.  I was hoping you could
 clarify it for me.
 
 Do you mean that it was a bug in 2.95.2, that it should have instantiated
 the declarations (and thus, failed to compile)?
 And, further, that 3.0.4 is correct in its failure to compile?
 
 I'm not sure what a "regression from gcc-3.0.4" means (as stated in the
 Audit Trail).
 
 Leick
 
 
 Gabriel Dos Reis wrote:
 
 > leick.robinson@motorola.com writes:
 >
 > | This assumes that the rule for an uninstantiated member
 > | function extends to its declaration.  I am not certain
 > | whether the C++ standard is clear on this point.
 >
 > You're right:  This is a bug in g++, it should have instantiated the
 > *declarations* of the member functions.  I'll mark it as a regression.
 >
 > Thanks,
 >
 > -- Gaby
 
 --
  ____________________________________________________________________
 |  Leick Robinson --> "bRoken siLicon"                               |
 |  Manager, PowerPC Core Modeling Team                               |
 |                                                                    |
 |  Phone: (512) 996-4948                          \O/   BE OF        |
 |  Pager: (512) 1-888-561-6477                     |   GOOD    \ /   |
 |  Email: leick.robinson@motorola.com             / \   CHEER!  |    |
 |                    PowerPC System Enablement                 /O\   |
 |                          Motorola-Austin                           |
 |                                                                    |
 |  "There exists a passion for comprehension, just as there exists   |
 |  a passion for music.  That passion is rather common in children,  |
 |  but gets lost in most people later on."  -- A. Einstein, 1950     |
 |____________________________________________________________________|
 
 
 
 --------------71CDC3598563AC3C410BB7D1
 Content-Type: text/html; charset=us-ascii
 Content-Transfer-Encoding: 7bit
 
 <!doctype html public "-//w3c//dtd html 4.0 transitional//en">
 <html>
 Gabriel,
 <p>I'm not sure I fully understand your response.&nbsp; I was hoping you
 could clarify it for me.
 <p>Do you mean that it was a bug in 2.95.2, that it should have instantiated
 the declarations (and thus, failed to compile)?
 <br>And, further, that 3.0.4 is correct in its failure to compile?
 <p>I'm not sure what a "regression from gcc-3.0.4" means (as stated in
 the Audit Trail).
 <p>Leick
 <br>&nbsp;
 <p>Gabriel Dos Reis wrote:
 <blockquote TYPE=CITE>leick.robinson@motorola.com writes:
 <p>| This assumes that the rule for an uninstantiated member
 <br>| function extends to its declaration.&nbsp; I am not certain
 <br>| whether the C++ standard is clear on this point.
 <p>You're right:&nbsp; This is a bug in g++, it should have instantiated
 the
 <br>*declarations* of the member functions.&nbsp; I'll mark it as a regression.
 <p>Thanks,
 <p>-- Gaby</blockquote>
 
 <pre>--&nbsp;
 &nbsp;____________________________________________________________________
 |&nbsp; Leick Robinson --> "bRoken siLicon"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n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&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |
 |&nbsp; "There exists a passion for comprehension, just as there exists&nbsp;&nbsp; |
 |&nbsp; a passion for music.&nbsp; That passion is rather common in children,&nbsp; |
 |&nbsp; but gets lost in most people later on."&nbsp; -- A. Einstein, 1950&nbsp;&nbsp;&nbsp;&nbsp; |
 |____________________________________________________________________|</pre>
 &nbsp;</html>
 
 --------------71CDC3598563AC3C410BB7D1--
 


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

* Re: c++/7686: template compilation failure on unused method
@ 2002-08-22 16:26 gdr
  0 siblings, 0 replies; 6+ messages in thread
From: gdr @ 2002-08-22 16:26 UTC (permalink / raw)
  To: gcc-bugs, gcc-prs, leick.robinson, nobody

Synopsis: template compilation failure on unused method

State-Changed-From-To: open->analyzed
State-Changed-By: gdr
State-Changed-When: Thu Aug 22 16:19:35 2002
State-Changed-Why:
    Confirmed.  A regression from GCC-3.0.4

http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=7686


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

* c++/7686: template compilation failure on unused method
@ 2002-08-22 13:26 leick.robinson
  0 siblings, 0 replies; 6+ messages in thread
From: leick.robinson @ 2002-08-22 13:26 UTC (permalink / raw)
  To: gcc-gnats


>Number:         7686
>Category:       c++
>Synopsis:       template compilation failure on unused method
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          rejects-legal
>Submitter-Id:   net
>Arrival-Date:   Thu Aug 22 12:06:00 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator:     leick.robinson@motorola.com
>Release:        gcc version 3.0.4
>Organization:
>Environment:
SUNW,Ultra-60
SunOS 5.8
>Description:
C++ does not instantiate a member function for a template
class unless the member function is actually used.  If the 
member function is not instantiated, the compiler does not 
check the member function (or rather, this particular 
instantiation) for compilation errors.

So, in the code example that follows, although the second
form of foo, foo(T t), would obviously not compile for
A<void>, since it is never called, A<void>::foo(void t) is
never instantiated, and in the past this has not caused
any problems with compilation.

This assumes that the rule for an uninstantiated member 
function extends to its declaration.  I am not certain
whether the C++ standard is clear on this point.

This compiles and runs without difficulties on gcc 2.95.2.
However, it fails to compile for gcc 3.0.4 (with the error
message:  In instantiation of `A<void>': invalid parameter
type `void' in declaration `void A<T>::foo(T)'

>How-To-Repeat:
// Compile this code:

#include <iostream>
using namespace std;

template <class T>
class A {
public:
   void foo()
   {
      cout << "Calling foo()" << endl;
   }

   void foo(T t)
   {
      cout << "Calling foo(T)" << endl;
   }
};

int main()
{
   A<int> a;  // Just to show that it works normally
   a.foo();
   a.foo(3);

   A<void> b;  // This instantiation compiles with 2.95.2,
               // but not with 3.0.4
   b.foo();
}
>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:


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

end of thread, other threads:[~2002-10-16 17:21 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-08-22 16:56 c++/7686: template compilation failure on unused method Gabriel Dos Reis
  -- strict thread matches above, loose matches on Subject: below --
2002-10-16 10:21 mmitchel
2002-08-23  9:36 Gabriel Dos Reis
2002-08-23  8:46 Leick Robinson
2002-08-22 16:26 gdr
2002-08-22 13:26 leick.robinson

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