public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "bangerth at dealii dot org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/17971] [3.4/4.0 regression] Invalid default parameter not diagnosed.
Date: Wed, 13 Oct 2004 12:50:00 -0000	[thread overview]
Message-ID: <20041013125043.6759.qmail@sourceware.org> (raw)
In-Reply-To: <20041013093830.17971.reichelt@gcc.gnu.org>


------- 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<typename> struct A {}; 
 
template<typename T> struct B 
{ 
    A<T> a; 
 
    void foo(A<T> = a); 
}; 
 
void bar () 
{ 
  B<int>().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<int>::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<class T> T g(T = &p); 
     template int g<int>(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


  parent reply	other threads:[~2004-10-13 12:50 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-10-13  9:38 [Bug c++/17971] New: " reichelt at gcc dot gnu dot org
2004-10-13 12:22 ` [Bug c++/17971] " pinskia at gcc dot gnu dot org
2004-10-13 12:50 ` bangerth at dealii dot org [this message]
2004-11-01  0:46 ` mmitchel at gcc dot gnu dot org
2004-11-28  6:03 ` lerdsuwa at gcc dot gnu dot org
2004-12-03 10:25 ` lerdsuwa at gcc dot gnu dot org
2004-12-04  7:07 ` lerdsuwa at gcc dot gnu dot org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20041013125043.6759.qmail@sourceware.org \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).