public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/27115]  New: [4.0/4.1/4.2 Regression] ICE in cp_expr_size or miscompilation
@ 2006-04-11  8:59 jakub at gcc dot gnu dot org
  2006-04-11  9:01 ` [Bug c++/27115] " jakub at gcc dot gnu dot org
                   ` (10 more replies)
  0 siblings, 11 replies; 12+ messages in thread
From: jakub at gcc dot gnu dot org @ 2006-04-11  8:59 UTC (permalink / raw)
  To: gcc-bugs

struct S
{
  S () : d(1.0) {}
  S (const double &x) : d(x) {}
  S (const S &x) : d(x.d) {}
  const S &operator= (const S &x) { d = x.d; return *this; }
  bool operator< (const S &x) const { return d < x.d; }
  double d;
};

S
foo (S a, S b)
{
  S c = ({ (a < b) ? a : b; });
  return c;
}

extern "C" void abort ();

int
main (void)
{
  S a = 6.0, b = 8.0, c = 10.0, r;
  r = foo (a, b);
  if (r.d != 6.0)
    abort ();
  r = foo (c, a);
  if (r.d != 6.0)
    abort ();
  r = foo (c, b);
  if (r.d != 8.0)
    abort ();
  return 0;
}

ICEs in cp_expr_size at -O0 and is miscompiled at -O2.
After gimplification foo looks like:
S foo(S, S) (a, b)
{
  struct S & c.0;
  struct S D.2401;
  bool D.2405;
  struct S c;

  (void) 0;
  c.0 = <retval>;
  D.2405 = operator< (a, b);
  *c.0 = D.2401;
  return <retval>;
}
so D.2401 is undefined and D.2405 is unused.  Before gimplification it is:
{
  struct S c;

  (void) 0;
  <<cleanup_point <<< Unknown tree: expr_stmt
  (void) (*<retval> = TARGET_EXPR <D.2401, <<cleanup_point <<< Unknown tree:
expr_stmt
  if (operator< ((struct S *) a, (struct S &) (struct S *) (struct S *) b))
    {
      (void) *a;
    }
  else
    {
      (void) *b;
    } >>>
>>>) >>>
>>;
  <<cleanup_point return <retval>>>;
}
which looks ok.
With GCC 3.4.x the test passed at all optimization levels.


-- 
           Summary: [4.0/4.1/4.2 Regression] ICE in cp_expr_size or
                    miscompilation
           Product: gcc
           Version: 4.1.1
            Status: UNCONFIRMED
          Severity: critical
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: jakub at gcc dot gnu dot org


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


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

* [Bug c++/27115] [4.0/4.1/4.2 Regression] ICE in cp_expr_size or miscompilation
  2006-04-11  8:59 [Bug c++/27115] New: [4.0/4.1/4.2 Regression] ICE in cp_expr_size or miscompilation jakub at gcc dot gnu dot org
@ 2006-04-11  9:01 ` jakub at gcc dot gnu dot org
  2006-04-11 17:41 ` pinskia at gcc dot gnu dot org
                   ` (9 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: jakub at gcc dot gnu dot org @ 2006-04-11  9:01 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from jakub at gcc dot gnu dot org  2006-04-11 09:01 -------
Well, the (void) *a; and (void) *b; certainly don't look ok, so the problem
is earlier.  Sorry.


-- 


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


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

* [Bug c++/27115] [4.0/4.1/4.2 Regression] ICE in cp_expr_size or miscompilation
  2006-04-11  8:59 [Bug c++/27115] New: [4.0/4.1/4.2 Regression] ICE in cp_expr_size or miscompilation jakub at gcc dot gnu dot org
  2006-04-11  9:01 ` [Bug c++/27115] " jakub at gcc dot gnu dot org
@ 2006-04-11 17:41 ` pinskia at gcc dot gnu dot org
  2006-04-12 11:34 ` reichelt at gcc dot gnu dot org
                   ` (8 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-04-11 17:41 UTC (permalink / raw)
  To: gcc-bugs



-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |ice-on-valid-code, wrong-
                   |                            |code
   Target Milestone|---                         |4.0.4


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


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

* [Bug c++/27115] [4.0/4.1/4.2 Regression] ICE in cp_expr_size or miscompilation
  2006-04-11  8:59 [Bug c++/27115] New: [4.0/4.1/4.2 Regression] ICE in cp_expr_size or miscompilation jakub at gcc dot gnu dot org
  2006-04-11  9:01 ` [Bug c++/27115] " jakub at gcc dot gnu dot org
  2006-04-11 17:41 ` pinskia at gcc dot gnu dot org
@ 2006-04-12 11:34 ` reichelt at gcc dot gnu dot org
  2006-04-12 12:11 ` reichelt at gcc dot gnu dot org
                   ` (7 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: reichelt at gcc dot gnu dot org @ 2006-04-12 11:34 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from reichelt at gcc dot gnu dot org  2006-04-12 11:34 -------
Confirmed.
Shorter testcase that crashes at -O0:

================================
struct A
{
    A (const A&);
    A& operator= (const A&);
};

void foo(A a)
{
    A b = ({ a; });
}
================================

bug.cc: In function 'void foo(A)':
bug.cc:9: internal compiler error: in cp_expr_size, at cp/cp-objcp-common.c:101
Please submit a full bug report, [etc.]

The problem seems to be the statement-expression.
Just initializing "A b = a;" makes the ICE go away.


-- 

reichelt at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |reichelt at gcc dot gnu dot
                   |                            |org
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|0                           |1
           Keywords|                            |monitored
   Last reconfirmed|0000-00-00 00:00:00         |2006-04-12 11:34:16
               date|                            |
   Target Milestone|4.0.4                       |4.1.1


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


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

* [Bug c++/27115] [4.0/4.1/4.2 Regression] ICE in cp_expr_size or miscompilation
  2006-04-11  8:59 [Bug c++/27115] New: [4.0/4.1/4.2 Regression] ICE in cp_expr_size or miscompilation jakub at gcc dot gnu dot org
                   ` (2 preceding siblings ...)
  2006-04-12 11:34 ` reichelt at gcc dot gnu dot org
@ 2006-04-12 12:11 ` reichelt at gcc dot gnu dot org
  2006-04-13  1:17 ` [Bug c++/27115] [4.0/4.1/4.2 Regression] ICE in cp_expr_size or miscompilation with statement expressions and constructors (and ?: ) pinskia at gcc dot gnu dot org
                   ` (6 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: reichelt at gcc dot gnu dot org @ 2006-04-12 12:11 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from reichelt at gcc dot gnu dot org  2006-04-12 12:11 -------
Here's a shorter testcase for the wrong-code problem (using "-O"):
It should return 0, but returns something else since GCC 4.0.2.
The compiler crashes on this testcase with GCC 3.3 - 4.0.1.

=========================================================
struct A
{
  int i;
  A (int j) : i(j) {}
  A (const A &j) : i(j.i) {}
  A& operator= (const A &j) { i = j.i; return *this; }
};

A foo(int j)
{
  return ({ j ? A(1) : A(0); });
}

int main()
{
  return foo(1).i-1;
}
=========================================================


-- 


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


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

* [Bug c++/27115] [4.0/4.1/4.2 Regression] ICE in cp_expr_size or miscompilation with statement expressions and constructors (and ?: )
  2006-04-11  8:59 [Bug c++/27115] New: [4.0/4.1/4.2 Regression] ICE in cp_expr_size or miscompilation jakub at gcc dot gnu dot org
                   ` (3 preceding siblings ...)
  2006-04-12 12:11 ` reichelt at gcc dot gnu dot org
@ 2006-04-13  1:17 ` pinskia at gcc dot gnu dot org
  2006-06-04 18:25 ` mmitchel at gcc dot gnu dot org
                   ` (5 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-04-13  1:17 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from pinskia at gcc dot gnu dot org  2006-04-13 01:17 -------
for the orginal expample:
3.3.3 ICE
3.4.0 worked
3.2.2 ICE
3.0.4 ICE
2.95.3 ICE

I don't think we should call this critical as this is using an extension in the
first place and it only ICEs with the extension in fact.


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|critical                    |normal
            Summary|[4.0/4.1/4.2 Regression] ICE|[4.0/4.1/4.2 Regression] ICE
                   |in cp_expr_size or          |in cp_expr_size or
                   |miscompilation with         |miscompilation with
                   |statement expressions and   |statement expressions and
                   |constructors                |constructors (and ?: )
   Target Milestone|4.1.1                       |4.0.4


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


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

* [Bug c++/27115] [4.0/4.1/4.2 Regression] ICE in cp_expr_size or miscompilation with statement expressions and constructors (and ?: )
  2006-04-11  8:59 [Bug c++/27115] New: [4.0/4.1/4.2 Regression] ICE in cp_expr_size or miscompilation jakub at gcc dot gnu dot org
                   ` (4 preceding siblings ...)
  2006-04-13  1:17 ` [Bug c++/27115] [4.0/4.1/4.2 Regression] ICE in cp_expr_size or miscompilation with statement expressions and constructors (and ?: ) pinskia at gcc dot gnu dot org
@ 2006-06-04 18:25 ` mmitchel at gcc dot gnu dot org
  2006-08-14 22:22 ` pinskia at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: mmitchel at gcc dot gnu dot org @ 2006-06-04 18:25 UTC (permalink / raw)
  To: gcc-bugs



-- 

mmitchel at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P2


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


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

* [Bug c++/27115] [4.0/4.1/4.2 Regression] ICE in cp_expr_size or miscompilation with statement expressions and constructors (and ?: )
  2006-04-11  8:59 [Bug c++/27115] New: [4.0/4.1/4.2 Regression] ICE in cp_expr_size or miscompilation jakub at gcc dot gnu dot org
                   ` (5 preceding siblings ...)
  2006-06-04 18:25 ` mmitchel at gcc dot gnu dot org
@ 2006-08-14 22:22 ` pinskia at gcc dot gnu dot org
  2006-08-21 20:55 ` jason at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-08-14 22:22 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from pinskia at gcc dot gnu dot org  2006-08-14 22:22 -------
*** Bug 28730 has been marked as a duplicate of this bug. ***


-- 


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


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

* [Bug c++/27115] [4.0/4.1/4.2 Regression] ICE in cp_expr_size or miscompilation with statement expressions and constructors (and ?: )
  2006-04-11  8:59 [Bug c++/27115] New: [4.0/4.1/4.2 Regression] ICE in cp_expr_size or miscompilation jakub at gcc dot gnu dot org
                   ` (6 preceding siblings ...)
  2006-08-14 22:22 ` pinskia at gcc dot gnu dot org
@ 2006-08-21 20:55 ` jason at gcc dot gnu dot org
  2006-08-22 18:41 ` [Bug c++/27115] [4.0/4.1 " jason at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: jason at gcc dot gnu dot org @ 2006-08-21 20:55 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from jason at gcc dot gnu dot org  2006-08-21 20:55 -------
Subject: Bug 27115

Author: jason
Date: Mon Aug 21 20:54:57 2006
New Revision: 116311

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=116311
Log:
        PR c++/27115
        * gimplify.c (voidify_wrapper_expr): Handle STATEMENT_LIST as a
        wrapper.  Loop to handle nested wrappers.
        (gimplify_bind_expr): Remove temp parameter.
        (gimplify_modify_expr_rhs): Handle CLEANUP_POINT_EXPR, BIND_EXPR
        and STATEMENT_LIST on the rhs.
        (gimplify_statement_list): Voidify the STATEMENT_LIST.
        (gimplify_expr): Pass pre_p to gimplify_statement_list.
        (gimplify_target_expr): Remove special BIND_EXPR handling.
        * cp/semantics.c (finish_stmt_expr_expr): Don't try to voidify here,
        just leave the expression as it is.
        (finish_stmt_expr): If the statement-expression has class type,
        wrap it in a TARGET_EXPR.
        * cp/cp-gimplify.c (cp_gimplify_init_expr): Don't bother with
        CLEANUP_POINT_EXPR.
        * cp/except.c (build_throw): Give the CLEANUP_POINT_EXPR void type.

Added:
    trunk/gcc/testsuite/g++.dg/abi/forced-sticky.C
    trunk/gcc/testsuite/g++.dg/abi/forced.C
    trunk/gcc/testsuite/g++.dg/ext/stmtexpr8.C
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/cp-gimplify.c
    trunk/gcc/cp/except.c
    trunk/gcc/cp/semantics.c
    trunk/gcc/gimplify.c


-- 


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


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

* [Bug c++/27115] [4.0/4.1 Regression] ICE in cp_expr_size or miscompilation with statement expressions and constructors (and ?: )
  2006-04-11  8:59 [Bug c++/27115] New: [4.0/4.1/4.2 Regression] ICE in cp_expr_size or miscompilation jakub at gcc dot gnu dot org
                   ` (7 preceding siblings ...)
  2006-08-21 20:55 ` jason at gcc dot gnu dot org
@ 2006-08-22 18:41 ` jason at gcc dot gnu dot org
  2006-09-01  6:11 ` pinskia at gcc dot gnu dot org
  2007-07-15 21:14 ` pinskia at gcc dot gnu dot org
  10 siblings, 0 replies; 12+ messages in thread
From: jason at gcc dot gnu dot org @ 2006-08-22 18:41 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #7 from jason at gcc dot gnu dot org  2006-08-22 18:41 -------
This is too big a change to apply to 4.0 or 4.1, so WONTFIX there.


-- 

jason at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED


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


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

* [Bug c++/27115] [4.0/4.1 Regression] ICE in cp_expr_size or miscompilation with statement expressions and constructors (and ?: )
  2006-04-11  8:59 [Bug c++/27115] New: [4.0/4.1/4.2 Regression] ICE in cp_expr_size or miscompilation jakub at gcc dot gnu dot org
                   ` (8 preceding siblings ...)
  2006-08-22 18:41 ` [Bug c++/27115] [4.0/4.1 " jason at gcc dot gnu dot org
@ 2006-09-01  6:11 ` pinskia at gcc dot gnu dot org
  2007-07-15 21:14 ` pinskia at gcc dot gnu dot org
  10 siblings, 0 replies; 12+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-09-01  6:11 UTC (permalink / raw)
  To: gcc-bugs



-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|4.0.4                       |4.2.0


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


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

* [Bug c++/27115] [4.0/4.1 Regression] ICE in cp_expr_size or miscompilation with statement expressions and constructors (and ?: )
  2006-04-11  8:59 [Bug c++/27115] New: [4.0/4.1/4.2 Regression] ICE in cp_expr_size or miscompilation jakub at gcc dot gnu dot org
                   ` (9 preceding siblings ...)
  2006-09-01  6:11 ` pinskia at gcc dot gnu dot org
@ 2007-07-15 21:14 ` pinskia at gcc dot gnu dot org
  10 siblings, 0 replies; 12+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2007-07-15 21:14 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #8 from pinskia at gcc dot gnu dot org  2007-07-15 21:14 -------
*** Bug 32767 has been marked as a duplicate of this bug. ***


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bisqwit at iki dot fi


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


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

end of thread, other threads:[~2007-07-15 21:14 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-04-11  8:59 [Bug c++/27115] New: [4.0/4.1/4.2 Regression] ICE in cp_expr_size or miscompilation jakub at gcc dot gnu dot org
2006-04-11  9:01 ` [Bug c++/27115] " jakub at gcc dot gnu dot org
2006-04-11 17:41 ` pinskia at gcc dot gnu dot org
2006-04-12 11:34 ` reichelt at gcc dot gnu dot org
2006-04-12 12:11 ` reichelt at gcc dot gnu dot org
2006-04-13  1:17 ` [Bug c++/27115] [4.0/4.1/4.2 Regression] ICE in cp_expr_size or miscompilation with statement expressions and constructors (and ?: ) pinskia at gcc dot gnu dot org
2006-06-04 18:25 ` mmitchel at gcc dot gnu dot org
2006-08-14 22:22 ` pinskia at gcc dot gnu dot org
2006-08-21 20:55 ` jason at gcc dot gnu dot org
2006-08-22 18:41 ` [Bug c++/27115] [4.0/4.1 " jason at gcc dot gnu dot org
2006-09-01  6:11 ` pinskia at gcc dot gnu dot org
2007-07-15 21:14 ` pinskia 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).