From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28178 invoked by alias); 22 Aug 2002 19:06:00 -0000 Mailing-List: contact gcc-prs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-prs-owner@gcc.gnu.org Received: (qmail 28160 invoked by uid 71); 22 Aug 2002 19:06:00 -0000 Resent-Date: 22 Aug 2002 19:06:00 -0000 Resent-Message-ID: <20020822190600.28159.qmail@sources.redhat.com> Resent-From: gcc-gnats@gcc.gnu.org (GNATS Filer) Resent-Cc: gcc-prs@gcc.gnu.org, gcc-bugs@gcc.gnu.org Resent-Reply-To: gcc-gnats@gcc.gnu.org, leick.robinson@motorola.com Received: (qmail 25551 invoked by uid 61); 22 Aug 2002 18:58:13 -0000 Message-Id: <20020822185813.25550.qmail@sources.redhat.com> Date: Thu, 22 Aug 2002 13:26:00 -0000 From: leick.robinson@motorola.com Reply-To: leick.robinson@motorola.com To: gcc-gnats@gcc.gnu.org X-Send-Pr-Version: gnatsweb-2.9.3 (1.1.1.1.2.31) Subject: c++/7686: template compilation failure on unused method X-SW-Source: 2002-08/txt/msg00465.txt.bz2 List-Id: >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, since it is never called, A::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': invalid parameter type `void' in declaration `void A::foo(T)' >How-To-Repeat: // Compile this code: #include using namespace std; template class A { public: void foo() { cout << "Calling foo()" << endl; } void foo(T t) { cout << "Calling foo(T)" << endl; } }; int main() { A a; // Just to show that it works normally a.foo(); a.foo(3); A b; // This instantiation compiles with 2.95.2, // but not with 3.0.4 b.foo(); } >Fix: >Release-Note: >Audit-Trail: >Unformatted: