Bug 36575 - [4.3/4.4 Regression] ACATS c460011 fails at -O3
Summary: [4.3/4.4 Regression] ACATS c460011 fails at -O3
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: middle-end (show other bugs)
Version: 4.4.0
: P4 normal
Target Milestone: 4.3.3
Assignee: Eric Botcazou
URL:
Keywords: wrong-code
Depends on:
Blocks:
 
Reported: 2008-06-19 06:53 UTC by Laurent GUERBY
Modified: 2008-09-28 15:20 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2008-09-26 08:43:40


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Laurent GUERBY 2008-06-19 06:53:43 UTC
When compiled with 4.2.4 at -O3 -gnato cg460011 passes:

,.,. C460011 ACATS 2.5 08-06-19 08:49:17
---- C460011 Check that conversion to a modular type raises
                Constraint_Error when the operand value is outside the
                base range of the modular type.
==== C460011 PASSED ============================.

Whereas when compiled at -O3 -gnato on 4.3.1 and 4.4 20080618 it fails:

,.,. C460011 ACATS 2.5 08-06-19 08:49:17
---- C460011 Check that conversion to a modular type raises
                Constraint_Error when the operand value is outside the
                base range of the modular type.
==== C460011 PASSED ============================.

To reproduce:

$ gnatchop ../../trunk/gcc/testsuite/ada/acats/support/rep* ../../trunk/gcc/testsuite/ada/acats/tests/c4/c460011.a
$ gnatmake -O3 -gnato c460011.adb
$ ./c460011
Comment 1 Laurent GUERBY 2008-06-19 06:54:23 UTC
Ooops paster the wrong output, the FAILED message with 4.3.1/4.4 is:

,.,. C460011 ACATS 2.5 08-06-19 08:51:01
---- C460011 Check that conversion to a modular type raises
                Constraint_Error when the operand value is outside the
                base range of the modular type.
   * C460011 Halfway => Big, 3.
   * C460011 Halfway => Also_Big, 3.
   * C460011 Halfway => Also_Big, -3.
**** C460011 FAILED ****************************.
Comment 2 Richard Biener 2008-06-21 16:33:15 UTC
I would bet this is VRP triggered by more inlining.
Comment 3 Joseph S. Myers 2008-06-22 11:03:16 UTC
Setting to P4 as an Ada bug, please restore to P3 if a C or C++ testcase is found.
Comment 4 Joseph S. Myers 2008-08-27 22:04:41 UTC
4.3.2 is released, changing milestones to 4.3.3.
Comment 5 Eric Botcazou 2008-09-26 08:43:19 UTC
Reproducible on x86.
Comment 6 Eric Botcazou 2008-09-26 08:43:40 UTC
Investigating.
Comment 7 Eric Botcazou 2008-09-26 09:24:59 UTC
> I would bet this is VRP triggered by more inlining.

It's constant-folding triggered by more inlining, this already fails at -O0:

procedure P is

  type Unsigned_Over_8 is mod 2**8+2;
  type Signed_Over_8 is range -200 .. 200;

  procedure Assert(Truth: Boolean) is
  begin
    if not Truth then
      raise Program_Error;
    end if;
  end;

  type Decim is delta 0.1 digits 5;

  Halfway  : Decim := 2.5;
  Neg_Half : Decim := -2.5;

  Big      : Unsigned_Over_8;
  Also_Big : Signed_Over_8;

begin
  Big := Unsigned_Over_8 (Halfway); -- Rounds up by 4.6(33).
  Assert(Big = 3);

  Also_Big := Signed_Over_8 (Halfway); -- Rounds up by 4.6(33).
  Assert(Also_Big = 3);

  Also_Big := Signed_Over_8 (Neg_Half); -- Rounds down by 4.6(33).
  Assert(Also_Big = -3);
end;
Comment 8 Eric Botcazou 2008-09-28 15:13:40 UTC
Subject: Bug 36575

Author: ebotcazou
Date: Sun Sep 28 15:12:07 2008
New Revision: 140734

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=140734
Log:
	PR middle-end/36575
	* fold-const (div_and_round_double) <ROUND_DIV_EXPR>: Fix typo.

Added:
    trunk/gcc/testsuite/gnat.dg/conv_decimal.adb
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/fold-const.c
    trunk/gcc/testsuite/ChangeLog

Comment 9 Eric Botcazou 2008-09-28 15:15:15 UTC
Subject: Bug 36575

Author: ebotcazou
Date: Sun Sep 28 15:13:52 2008
New Revision: 140735

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=140735
Log:
	PR middle-end/36575
	* fold-const (div_and_round_double) <ROUND_DIV_EXPR>: Fix typo.

Added:
    branches/gcc-4_3-branch/gcc/testsuite/gnat.dg/conv_decimal.adb
Modified:
    branches/gcc-4_3-branch/gcc/ChangeLog
    branches/gcc-4_3-branch/gcc/fold-const.c
    branches/gcc-4_3-branch/gcc/testsuite/ChangeLog

Comment 10 Eric Botcazou 2008-09-28 15:16:41 UTC
Subject: Bug 36575

Author: ebotcazou
Date: Sun Sep 28 15:15:16 2008
New Revision: 140736

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=140736
Log:
	PR middle-end/36575
	* fold-const (div_and_round_double) <ROUND_DIV_EXPR>: Fix typo.

Added:
    branches/gcc-4_2-branch/gcc/testsuite/gnat.dg/conv_decimal.adb
Modified:
    branches/gcc-4_2-branch/gcc/ChangeLog
    branches/gcc-4_2-branch/gcc/fold-const.c
    branches/gcc-4_2-branch/gcc/testsuite/ChangeLog

Comment 11 Eric Botcazou 2008-09-28 15:20:46 UTC
Thanks for reporting the problem.