public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/39055]  New: [4.2/4.3/4.4 regression] ICE with questionable default parameter of a member function
@ 2009-02-01 10:16 reichelt at gcc dot gnu dot org
  2009-02-01 10:16 ` [Bug c++/39055] " reichelt at gcc dot gnu dot org
                   ` (13 more replies)
  0 siblings, 14 replies; 15+ messages in thread
From: reichelt at gcc dot gnu dot org @ 2009-02-01 10:16 UTC (permalink / raw)
  To: gcc-bugs

The following valid code snippet triggers an ICE since GCC 3.4.0:

==============================
template<int> struct A
{
  int i;
  A() { void foo(int=i); }
};

A<0> a;
==============================

bug.cc: In function 'void foo(int) [with int <anonymous> = 0]':
bug.cc:4:   instantiated from 'A<<anonymous> >::A() [with int <anonymous> = 0]'
bug.cc:7:   instantiated from here
bug.cc:4: internal compiler error: Segmentation fault
Please submit a full bug report, [etc.]

GCC 3.3.x wrongly rejected the code ('i' as default parameter is not OK,
but this should only be diagnosed if the default parameter is actually used).

GCC 3.[012].x correctly accepted the code.

Btw, the code compiles fine if A is not a template class.


-- 
           Summary: [4.2/4.3/4.4 regression] ICE with questionable default
                    parameter of a member function
           Product: gcc
           Version: 4.4.0
            Status: UNCONFIRMED
          Keywords: ice-on-valid-code, monitored
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: reichelt at gcc dot gnu dot org


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


^ permalink raw reply	[flat|nested] 15+ messages in thread

* [Bug c++/39055] [4.2/4.3/4.4 regression] ICE with questionable default parameter of a member function
  2009-02-01 10:16 [Bug c++/39055] New: [4.2/4.3/4.4 regression] ICE with questionable default parameter of a member function reichelt at gcc dot gnu dot org
@ 2009-02-01 10:16 ` reichelt at gcc dot gnu dot org
  2009-02-01 10:58 ` rguenth at gcc dot gnu dot org
                   ` (12 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: reichelt at gcc dot gnu dot org @ 2009-02-01 10:16 UTC (permalink / raw)
  To: gcc-bugs



-- 

reichelt at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |4.2.5


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


^ permalink raw reply	[flat|nested] 15+ messages in thread

* [Bug c++/39055] [4.2/4.3/4.4 regression] ICE with questionable default parameter of a member function
  2009-02-01 10:16 [Bug c++/39055] New: [4.2/4.3/4.4 regression] ICE with questionable default parameter of a member function reichelt at gcc dot gnu dot org
  2009-02-01 10:16 ` [Bug c++/39055] " reichelt at gcc dot gnu dot org
@ 2009-02-01 10:58 ` rguenth at gcc dot gnu dot org
  2009-02-06  2:25 ` pinskia at gcc dot gnu dot org
                   ` (11 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2009-02-01 10:58 UTC (permalink / raw)
  To: gcc-bugs



-- 

rguenth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
      Known to work|                            |3.2.3
           Priority|P3                          |P2


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


^ permalink raw reply	[flat|nested] 15+ messages in thread

* [Bug c++/39055] [4.2/4.3/4.4 regression] ICE with questionable default parameter of a member function
  2009-02-01 10:16 [Bug c++/39055] New: [4.2/4.3/4.4 regression] ICE with questionable default parameter of a member function reichelt at gcc dot gnu dot org
  2009-02-01 10:16 ` [Bug c++/39055] " reichelt at gcc dot gnu dot org
  2009-02-01 10:58 ` rguenth at gcc dot gnu dot org
@ 2009-02-06  2:25 ` pinskia at gcc dot gnu dot org
  2009-02-12 23:23 ` bangerth at gmail dot com
                   ` (10 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2009-02-06  2:25 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from pinskia at gcc dot gnu dot org  2009-02-06 02:25 -------
Confirmed.


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|0                           |1
   Last reconfirmed|0000-00-00 00:00:00         |2009-02-06 02:25:48
               date|                            |


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


^ permalink raw reply	[flat|nested] 15+ messages in thread

* [Bug c++/39055] [4.2/4.3/4.4 regression] ICE with questionable default parameter of a member function
  2009-02-01 10:16 [Bug c++/39055] New: [4.2/4.3/4.4 regression] ICE with questionable default parameter of a member function reichelt at gcc dot gnu dot org
                   ` (2 preceding siblings ...)
  2009-02-06  2:25 ` pinskia at gcc dot gnu dot org
@ 2009-02-12 23:23 ` bangerth at gmail dot com
  2009-02-20  5:38 ` jason at gcc dot gnu dot org
                   ` (9 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: bangerth at gmail dot com @ 2009-02-12 23:23 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from bangerth at gmail dot com  2009-02-12 23:23 -------
I think the code is invalid. The name 'i' is non-dependent, so shouldn't
it be bound to the member variable at the point of definition?

W.


-- 

bangerth at gmail dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bangerth at gmail dot com


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


^ permalink raw reply	[flat|nested] 15+ messages in thread

* [Bug c++/39055] [4.2/4.3/4.4 regression] ICE with questionable default parameter of a member function
  2009-02-01 10:16 [Bug c++/39055] New: [4.2/4.3/4.4 regression] ICE with questionable default parameter of a member function reichelt at gcc dot gnu dot org
                   ` (3 preceding siblings ...)
  2009-02-12 23:23 ` bangerth at gmail dot com
@ 2009-02-20  5:38 ` jason at gcc dot gnu dot org
  2009-03-22 14:02 ` jason at gcc dot gnu dot org
                   ` (8 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: jason at gcc dot gnu dot org @ 2009-02-20  5:38 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from jason at gcc dot gnu dot org  2009-02-20 05:38 -------
Yes, "i" is bound to "this->i", which I believe is perfectly valid.  The
section of the standard that says that default arguments can't refer to "this"
means that default arguments of member functions can't refer to their own
"this" parameter; usage in this form is fine.


-- 


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


^ permalink raw reply	[flat|nested] 15+ messages in thread

* [Bug c++/39055] [4.2/4.3/4.4 regression] ICE with questionable default parameter of a member function
  2009-02-01 10:16 [Bug c++/39055] New: [4.2/4.3/4.4 regression] ICE with questionable default parameter of a member function reichelt at gcc dot gnu dot org
                   ` (4 preceding siblings ...)
  2009-02-20  5:38 ` jason at gcc dot gnu dot org
@ 2009-03-22 14:02 ` jason at gcc dot gnu dot org
  2009-03-31 21:09 ` [Bug c++/39055] [4.3/4.4/4.5 " jsm28 at gcc dot gnu dot org
                   ` (7 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: jason at gcc dot gnu dot org @ 2009-03-22 14:02 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from jason at gcc dot gnu dot org  2009-03-22 14:01 -------
I was wrong; the previous paragraph says "Local variables shall not be used in
default argument expressions."

3.3 was right to reject the testcase; delayed instantiation of default
arguments only applies to function templates and member functions of class
templates, not local declarations.  Furthermore, a template for which no valid
instantiation can be generated is ill-formed, though the implementation is not
required to give a diagnostic.


-- 

jason at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|ice-on-valid-code           |ice-on-invalid-code


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


^ permalink raw reply	[flat|nested] 15+ messages in thread

* [Bug c++/39055] [4.3/4.4/4.5 regression] ICE with questionable default parameter of a member function
  2009-02-01 10:16 [Bug c++/39055] New: [4.2/4.3/4.4 regression] ICE with questionable default parameter of a member function reichelt at gcc dot gnu dot org
                   ` (5 preceding siblings ...)
  2009-03-22 14:02 ` jason at gcc dot gnu dot org
@ 2009-03-31 21:09 ` jsm28 at gcc dot gnu dot org
  2009-07-18 11:26 ` reichelt at gcc dot gnu dot org
                   ` (6 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: jsm28 at gcc dot gnu dot org @ 2009-03-31 21:09 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from jsm28 at gcc dot gnu dot org  2009-03-31 21:08 -------
Closing 4.2 branch.


-- 

jsm28 at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|[4.2/4.3/4.4/4.5 regression]|[4.3/4.4/4.5 regression] ICE
                   |ICE with questionable       |with questionable default
                   |default parameter of a      |parameter of a member
                   |member function             |function
   Target Milestone|4.2.5                       |4.3.4


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


^ permalink raw reply	[flat|nested] 15+ messages in thread

* [Bug c++/39055] [4.3/4.4/4.5 regression] ICE with questionable default parameter of a member function
  2009-02-01 10:16 [Bug c++/39055] New: [4.2/4.3/4.4 regression] ICE with questionable default parameter of a member function reichelt at gcc dot gnu dot org
                   ` (6 preceding siblings ...)
  2009-03-31 21:09 ` [Bug c++/39055] [4.3/4.4/4.5 " jsm28 at gcc dot gnu dot org
@ 2009-07-18 11:26 ` reichelt at gcc dot gnu dot org
  2009-07-18 11:38 ` jason at gcc dot gnu dot org
                   ` (5 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: reichelt at gcc dot gnu dot org @ 2009-07-18 11:26 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from reichelt at gcc dot gnu dot org  2009-07-18 11:26 -------
GCC's history with this code is:

* GCC 2.95.3          rejects
* GCC 3.0   - 3.2.3   accepts
* GCC 3.3   - 3.3.6   rejects
* GCC 3.4.0 - 4.3.x   crashes
* GCC 4.4.0 - trunk   accepts

Without the template, only GCC 2.93.3 rejects the code, all other
versions accept it. Considering that also Intel and Comeau accept
the code (template and non-template version) I doubt that the code
is invalid.

Jason, you said:

> I was wrong; the previous paragraph says "Local variables shall not
> be used in default argument expressions."
> 3.3 was right to reject the testcase; 

IMHO "Local variables" refers to function local variables, so that
you were right in the first place (comment #3) and that the code is
indeed valid.

This would mean that we really can close the bug as fixed in GCC 4.4.0.


-- 

reichelt at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jason at gcc dot gnu dot org
           Keywords|                            |accepts-invalid
      Known to work|3.2.3                       |


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


^ permalink raw reply	[flat|nested] 15+ messages in thread

* [Bug c++/39055] [4.3/4.4/4.5 regression] ICE with questionable default parameter of a member function
  2009-02-01 10:16 [Bug c++/39055] New: [4.2/4.3/4.4 regression] ICE with questionable default parameter of a member function reichelt at gcc dot gnu dot org
                   ` (7 preceding siblings ...)
  2009-07-18 11:26 ` reichelt at gcc dot gnu dot org
@ 2009-07-18 11:38 ` jason at gcc dot gnu dot org
  2009-08-04 12:47 ` rguenth at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: jason at gcc dot gnu dot org @ 2009-07-18 11:38 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #7 from jason at gcc dot gnu dot org  2009-07-18 11:37 -------
But 'this' is local to the function as well, so I think the wording about
'this' can be interpreted in the light of the local variable wording to mean
that the testcase is ill-formed.

If, however, implementations agree on accepting the testcase, then perhaps the
standard should change, rather than the implementations.


-- 


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


^ permalink raw reply	[flat|nested] 15+ messages in thread

* [Bug c++/39055] [4.3/4.4/4.5 regression] ICE with questionable default parameter of a member function
  2009-02-01 10:16 [Bug c++/39055] New: [4.2/4.3/4.4 regression] ICE with questionable default parameter of a member function reichelt at gcc dot gnu dot org
                   ` (8 preceding siblings ...)
  2009-07-18 11:38 ` jason at gcc dot gnu dot org
@ 2009-08-04 12:47 ` rguenth at gcc dot gnu dot org
  2009-11-12 22:48 ` jason at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2009-08-04 12:47 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #8 from rguenth at gcc dot gnu dot org  2009-08-04 12:29 -------
GCC 4.3.4 is being released, adjusting target milestone.


-- 

rguenth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|4.3.4                       |4.3.5


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


^ permalink raw reply	[flat|nested] 15+ messages in thread

* [Bug c++/39055] [4.3/4.4/4.5 regression] ICE with questionable default parameter of a member function
  2009-02-01 10:16 [Bug c++/39055] New: [4.2/4.3/4.4 regression] ICE with questionable default parameter of a member function reichelt at gcc dot gnu dot org
                   ` (9 preceding siblings ...)
  2009-08-04 12:47 ` rguenth at gcc dot gnu dot org
@ 2009-11-12 22:48 ` jason at gcc dot gnu dot org
  2009-11-13 16:16 ` jason at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: jason at gcc dot gnu dot org @ 2009-11-12 22:48 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #9 from jason at gcc dot gnu dot org  2009-11-12 22:47 -------
Created an attachment (id=19007)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=19007&action=view)
patch

This patch makes G++ reject the testcase.  But I don't see the utility in
rejecting it, and since EDG also accepts it I'm raising an issue with the C++
committee.


-- 


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


^ permalink raw reply	[flat|nested] 15+ messages in thread

* [Bug c++/39055] [4.3/4.4/4.5 regression] ICE with questionable default parameter of a member function
  2009-02-01 10:16 [Bug c++/39055] New: [4.2/4.3/4.4 regression] ICE with questionable default parameter of a member function reichelt at gcc dot gnu dot org
                   ` (10 preceding siblings ...)
  2009-11-12 22:48 ` jason at gcc dot gnu dot org
@ 2009-11-13 16:16 ` jason at gcc dot gnu dot org
  2010-05-22 18:29 ` [Bug c++/39055] [4.3/4.4/4.5/4.6 " rguenth at gcc dot gnu dot org
  2010-06-07 15:52 ` jason at gcc dot gnu dot org
  13 siblings, 0 replies; 15+ messages in thread
From: jason at gcc dot gnu dot org @ 2009-11-13 16:16 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #10 from jason at gcc dot gnu dot org  2009-11-13 16:16 -------
Bumping down the priority since it doesn't ICE on 4.4+ and it's unclear whether
or not the code should be valid.


-- 

jason at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P2                          |P4


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


^ permalink raw reply	[flat|nested] 15+ messages in thread

* [Bug c++/39055] [4.3/4.4/4.5/4.6 regression] ICE with questionable default parameter of a member function
  2009-02-01 10:16 [Bug c++/39055] New: [4.2/4.3/4.4 regression] ICE with questionable default parameter of a member function reichelt at gcc dot gnu dot org
                   ` (11 preceding siblings ...)
  2009-11-13 16:16 ` jason at gcc dot gnu dot org
@ 2010-05-22 18:29 ` rguenth at gcc dot gnu dot org
  2010-06-07 15:52 ` jason at gcc dot gnu dot org
  13 siblings, 0 replies; 15+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2010-05-22 18:29 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #11 from rguenth at gcc dot gnu dot org  2010-05-22 18:13 -------
GCC 4.3.5 is being released, adjusting target milestone.


-- 

rguenth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|4.3.5                       |4.3.6


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


^ permalink raw reply	[flat|nested] 15+ messages in thread

* [Bug c++/39055] [4.3/4.4/4.5/4.6 regression] ICE with questionable default parameter of a member function
  2009-02-01 10:16 [Bug c++/39055] New: [4.2/4.3/4.4 regression] ICE with questionable default parameter of a member function reichelt at gcc dot gnu dot org
                   ` (12 preceding siblings ...)
  2010-05-22 18:29 ` [Bug c++/39055] [4.3/4.4/4.5/4.6 " rguenth at gcc dot gnu dot org
@ 2010-06-07 15:52 ` jason at gcc dot gnu dot org
  13 siblings, 0 replies; 15+ messages in thread
From: jason at gcc dot gnu dot org @ 2010-06-07 15:52 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #12 from jason at gcc dot gnu dot org  2010-06-07 15:51 -------
Suspending.


-- 

jason at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |SUSPENDED


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


^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2010-06-07 15:52 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-02-01 10:16 [Bug c++/39055] New: [4.2/4.3/4.4 regression] ICE with questionable default parameter of a member function reichelt at gcc dot gnu dot org
2009-02-01 10:16 ` [Bug c++/39055] " reichelt at gcc dot gnu dot org
2009-02-01 10:58 ` rguenth at gcc dot gnu dot org
2009-02-06  2:25 ` pinskia at gcc dot gnu dot org
2009-02-12 23:23 ` bangerth at gmail dot com
2009-02-20  5:38 ` jason at gcc dot gnu dot org
2009-03-22 14:02 ` jason at gcc dot gnu dot org
2009-03-31 21:09 ` [Bug c++/39055] [4.3/4.4/4.5 " jsm28 at gcc dot gnu dot org
2009-07-18 11:26 ` reichelt at gcc dot gnu dot org
2009-07-18 11:38 ` jason at gcc dot gnu dot org
2009-08-04 12:47 ` rguenth at gcc dot gnu dot org
2009-11-12 22:48 ` jason at gcc dot gnu dot org
2009-11-13 16:16 ` jason at gcc dot gnu dot org
2010-05-22 18:29 ` [Bug c++/39055] [4.3/4.4/4.5/4.6 " rguenth at gcc dot gnu dot org
2010-06-07 15:52 ` jason at gcc dot gnu dot org

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).