From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16736 invoked by alias); 26 Mar 2005 02:01:52 -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 16521 invoked by alias); 26 Mar 2005 02:01:44 -0000 Date: Sat, 26 Mar 2005 02:01:00 -0000 Message-ID: <20050326020144.16520.qmail@sourceware.org> From: "dave at boost-consulting dot com" To: gcc-bugs@gcc.gnu.org In-Reply-To: <20040410193158.14912.schnetter@aei.mpg.de> References: <20040410193158.14912.schnetter@aei.mpg.de> Reply-To: gcc-bugzilla@gcc.gnu.org Subject: [Bug c++/14912] Do not print default template arguments in error messages X-Bugzilla-Reason: CC X-SW-Source: 2005-03/txt/msg03060.txt.bz2 List-Id: ------- Additional Comments From dave at boost-consulting dot com 2005-03-26 02:01 ------- Subject: Re: Do not print default template arguments in error messages "gdr at integrable-solutions dot net" writes: > ------- Additional Comments From gdr at integrable-solutions dot net 2005-03-25 22:06 ------- > Subject: Re: Do not print default template arguments in error messages > > "giovannibajo at libero dot it" writes: > > | ------- Additional Comments From giovannibajo at libero dot it 2005-03-23 02:44 ------- > | I'll try to do this. This is a simple testcase: > | > | --------------------------- > | template > | struct A > | { > | typedef typename T::x x; > | }; > | void foo(void) > | { > | A a; > | } > | --------------------------- > | test.cc: At global scope: > | test.cc: In instantiation of 'A': > | test.cc:8: instantiated from here > | test.cc:4: error: 'void' is not a class, struct, or union type > | > | Do we want the error message to show 'A' or 'A'? In other words, > > Most of the time, we want to print what user wrote. That rule could be really bad in cases like: A::value> The actual identity of the 2nd argument is usually far more important at the point where the error is reported than seeing the way the user wrote it, and the deduction needed for the user to determine that foo::value is actually 0, 1, or whatever can be arbitrarily complicated. The user may have to look through an arbitrary number of template definitions in arbitrary locations, finding all specializations and essentially doing instantiation by hand. By contrast, finding out how a template argument was written is trivial because GCC gives you a nice backtrace where you will see each template in the instantiation chain being supplied with arguments. Please, I'm begging you not to go down this road. GCC is one of the only compilers that gets it right today (VC8 will follow), and all the ones that try to follow the "show how it was written" rule often give errors that are, for all practical purposes, unusable. If you make GCC work like the others, it will be a leap backwards and a terrible disservice to users. If you choose to show an argument that happens to match the default but was in fact supplied explicitly, I have no real objection. Just show it in its simplified normal form and do not try to show "what was written." If you never really meant to go in the direction I fear, I just ask that you try find a way to describe what you want that can't be misinterpreted the way I did. Someone might go off and do the wrong thing anyway unless it is expressed clearly. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14912