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

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