From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6773 invoked by alias); 13 Oct 2004 12:50:44 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 6760 invoked by uid 48); 13 Oct 2004 12:50:43 -0000 Date: Wed, 13 Oct 2004 12:50:00 -0000 Message-ID: <20041013125043.6759.qmail@sourceware.org> From: "bangerth at dealii dot org" To: gcc-bugs@gcc.gnu.org In-Reply-To: <20041013093830.17971.reichelt@gcc.gnu.org> References: <20041013093830.17971.reichelt@gcc.gnu.org> Reply-To: gcc-bugzilla@gcc.gnu.org Subject: [Bug c++/17971] [3.4/4.0 regression] Invalid default parameter not diagnosed. X-Bugzilla-Reason: CC X-SW-Source: 2004-10/txt/msg01735.txt.bz2 List-Id: ------- Additional Comments From bangerth at dealii dot org 2004-10-13 12:50 ------- I'm not sure this is a bug: the standard quite unmistakably says that default arguments aren't evaluated unless used. Now, if I try to use the default argument in your testcase, like so ------------------ template struct A {}; template struct B { A a; void foo(A = a); }; void bar () { B().foo(); } -------------------------- then I do get a sensible error: g/x> /home/bangerth/bin/gcc-4.0-pre/bin/c++ -c x.cc x.cc:5: error: invalid use of non-static data member `B::a' x.cc:12: error: from this location Can you say why the compiler should diagnose this earlier rather than later, given what the standard says? For reference: 14.7.2/9 says An explicit instantiation does not constitute a use of a default argument, so default argument instantiation is not done. [Example: char* p = 0; template T g(T = &p); template int g(int); // OK even though &p isn't an int. --end example] and there are more places like this. W. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17971