public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "giovannibajo at libero dot it" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/21903] Default argument of template function causes a compile-time error
Date: Sat, 04 Jun 2005 10:46:00 -0000	[thread overview]
Message-ID: <20050604104617.13056.qmail@sourceware.org> (raw)
In-Reply-To: <20050603201311.21903.SSacek@appsecinc.com>


------- Additional Comments From giovannibajo at libero dot it  2005-06-04 10:46 -------
I can't find anything in the standard which says that this should be an error, 
regardless of what Comeau does. This looks like a genuine bug in the parser, 
see parser.c:cp_parser_class_specifier: the parsing of the body of the in-
classe defined functions and default arguments is delayed until the whole class 
definition is parsed (this allows, eg., the body of in-class member functions 
to refer to other member functions which appear later within the struct 
definition).

There is some code which also delays inner functions until the outer function 
is finished:


  /* If this class is not itself within the scope of another class,
     then we need to parse the bodies of all of the queued function
     definitions.  Note that the queued functions defined in a class
     are not always processed immediately following the
     class-specifier for that class.  Consider:

       struct A {
         struct B { void f() { sizeof (A); } };
       };

     If `f' were processed before the processing of `A' were
     completed, there would be no way to compute the size of `A'.
     Note that the nesting we are interested in here is lexical --
     not the semantic nesting given by TYPE_CONTEXT.  In particular,
     for:

       struct A { struct B; };
       struct A::B { void f() { } };

     there is no need to delay the parsing of `A::B::f'.  */


I think this logic breaks down with instantiations: probably the DEFAULT_ARG 
nodes (representing an unparsed default argument) are copied from B<T> (generic 
template) into B<int> (implicit specialization created by instantiation), and 
never reparsed after that (in fact, I can't see how they could be put within 
parser->unparser_function_queue, which is private of the parser).

I did not check whether this is a regression or not.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|                            |1
   Last reconfirmed|0000-00-00 00:00:00         |2005-06-04 10:46:16
               date|                            |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21903


  parent reply	other threads:[~2005-06-04 10:46 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-06-03 20:13 [Bug c++/21903] New: " SSacek at appsecinc dot com
2005-06-03 20:22 ` [Bug c++/21903] " pinskia at gcc dot gnu dot org
2005-06-03 21:51 ` bangerth at dealii dot org
2005-06-03 22:03 ` pinskia at gcc dot gnu dot org
2005-06-03 22:27 ` bangerth at dealii dot org
2005-06-03 22:27 ` bangerth at dealii dot org
2005-06-03 23:09 ` pinskia at gcc dot gnu dot org
2005-06-04  4:37 ` bangerth at dealii dot org
2005-06-04 10:46 ` giovannibajo at libero dot it [this message]
2005-06-04 10:48 ` giovannibajo at libero dot it
2005-06-04 18:28 ` SSacek at appsecinc dot com
2005-06-04 19:17 ` SSacek at appsecinc dot com
2005-06-06  9:35 ` nathan at gcc dot gnu dot org
2005-06-06  9:45 ` giovannibajo at libero dot it
2005-06-06 14:27 ` [Bug c++/21903] [3.4/4.0/4.1 regression] " bangerth at dealii dot org
2005-06-06 14:28 ` bangerth at dealii dot org
2005-06-06 17:29 ` cvs-commit at gcc dot gnu dot org
2005-06-06 17:30 ` nathan at gcc dot gnu dot org
2005-06-09  7:47 ` [Bug c++/21903] [3.4/4.0 " cvs-commit at gcc dot gnu dot org
2005-06-09  7:47 ` [Bug c++/21903] [4.0 " nathan at gcc dot gnu dot org
2005-07-06 17:03 ` mmitchel at gcc dot gnu dot org
2005-07-12 11:28 ` nathan at gcc dot gnu dot org
2005-07-12 11:31 ` cvs-commit at gcc dot gnu dot org
2005-08-15 12:04 ` pinskia 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=20050604104617.13056.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).