public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug d/101640] New: d: Wrong evaluation order of binary expressions
@ 2021-07-27 11:19 ibuclaw at gdcproject dot org
  2021-07-28 11:19 ` [Bug d/101640] " cvs-commit at gcc dot gnu.org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: ibuclaw at gdcproject dot org @ 2021-07-27 11:19 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101640

            Bug ID: 101640
           Summary: d: Wrong evaluation order of binary expressions
           Product: gcc
           Version: 9.4.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: d
          Assignee: ibuclaw at gdcproject dot org
          Reporter: ibuclaw at gdcproject dot org
  Target Milestone: ---

Because of the use of fold_build2, the evaluation order is ignored in the
following example.
---
int fun(ref int);

int test(int i)
{
    return i + fun(i);
}

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

* [Bug d/101640] d: Wrong evaluation order of binary expressions
  2021-07-27 11:19 [Bug d/101640] New: d: Wrong evaluation order of binary expressions ibuclaw at gdcproject dot org
@ 2021-07-28 11:19 ` cvs-commit at gcc dot gnu.org
  2021-07-28 11:37 ` cvs-commit at gcc dot gnu.org
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-07-28 11:19 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101640

--- Comment #1 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Iain Buclaw <ibuclaw@gcc.gnu.org>:

https://gcc.gnu.org/g:54ec50bada94a8ff92edb04ee5216c27fa4bf942

commit r12-2565-g54ec50bada94a8ff92edb04ee5216c27fa4bf942
Author: Iain Buclaw <ibuclaw@gdcproject.org>
Date:   Tue Jul 27 13:24:34 2021 +0200

    d: Wrong evaluation order of binary expressions (PR101640)

    The use of fold_build2 can in some cases swap the order of its operands
    if that is the more optimal thing to do.  However this breaks semantic
    guarantee of left-to-right evaluation in D.

            PR d/101640

    gcc/d/ChangeLog:

            * expr.cc (binary_op): Use build2 instead of fold_build2.

    gcc/testsuite/ChangeLog:

            * gdc.dg/pr96429.d: Update test.
            * gdc.dg/pr101640.d: New test.

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

* [Bug d/101640] d: Wrong evaluation order of binary expressions
  2021-07-27 11:19 [Bug d/101640] New: d: Wrong evaluation order of binary expressions ibuclaw at gdcproject dot org
  2021-07-28 11:19 ` [Bug d/101640] " cvs-commit at gcc dot gnu.org
@ 2021-07-28 11:37 ` cvs-commit at gcc dot gnu.org
  2021-07-28 11:50 ` cvs-commit at gcc dot gnu.org
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-07-28 11:37 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101640

--- Comment #2 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-11 branch has been updated by Iain Buclaw
<ibuclaw@gcc.gnu.org>:

https://gcc.gnu.org/g:d3c268943c339e994802656ce71ef654cc2a349f

commit r11-8810-gd3c268943c339e994802656ce71ef654cc2a349f
Author: Iain Buclaw <ibuclaw@gdcproject.org>
Date:   Tue Jul 27 13:24:34 2021 +0200

    d: Wrong evaluation order of binary expressions (PR101640)

    The use of fold_build2 can in some cases swap the order of its operands
    if that is the more optimal thing to do.  However this breaks semantic
    guarantee of left-to-right evaluation in D.

            PR d/101640

    gcc/d/ChangeLog:

            * expr.cc (binary_op): Use build2 instead of fold_build2.

    gcc/testsuite/ChangeLog:

            * gdc.dg/pr96429.d: Update test.
            * gdc.dg/pr101640.d: New test.

    (cherry picked from commit 54ec50bada94a8ff92edb04ee5216c27fa4bf942)

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

* [Bug d/101640] d: Wrong evaluation order of binary expressions
  2021-07-27 11:19 [Bug d/101640] New: d: Wrong evaluation order of binary expressions ibuclaw at gdcproject dot org
  2021-07-28 11:19 ` [Bug d/101640] " cvs-commit at gcc dot gnu.org
  2021-07-28 11:37 ` cvs-commit at gcc dot gnu.org
@ 2021-07-28 11:50 ` cvs-commit at gcc dot gnu.org
  2021-07-28 11:57 ` cvs-commit at gcc dot gnu.org
  2021-07-28 12:48 ` ibuclaw at gdcproject dot org
  4 siblings, 0 replies; 6+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-07-28 11:50 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101640

--- Comment #3 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-10 branch has been updated by Iain Buclaw
<ibuclaw@gcc.gnu.org>:

https://gcc.gnu.org/g:9a16492f524eb46b4ba0375d2e2ebe0f62b72fa4

commit r10-10008-g9a16492f524eb46b4ba0375d2e2ebe0f62b72fa4
Author: Iain Buclaw <ibuclaw@gdcproject.org>
Date:   Tue Jul 27 13:24:34 2021 +0200

    d: Wrong evaluation order of binary expressions (PR101640)

    The use of fold_build2 can in some cases swap the order of its operands
    if that is the more optimal thing to do.  However this breaks semantic
    guarantee of left-to-right evaluation in D.

            PR d/101640

    gcc/d/ChangeLog:

            * expr.cc (binary_op): Use build2 instead of fold_build2.

    gcc/testsuite/ChangeLog:

            * gdc.dg/pr101640.d: New test.

    (cherry picked from commit 54ec50bada94a8ff92edb04ee5216c27fa4bf942)

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

* [Bug d/101640] d: Wrong evaluation order of binary expressions
  2021-07-27 11:19 [Bug d/101640] New: d: Wrong evaluation order of binary expressions ibuclaw at gdcproject dot org
                   ` (2 preceding siblings ...)
  2021-07-28 11:50 ` cvs-commit at gcc dot gnu.org
@ 2021-07-28 11:57 ` cvs-commit at gcc dot gnu.org
  2021-07-28 12:48 ` ibuclaw at gdcproject dot org
  4 siblings, 0 replies; 6+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-07-28 11:57 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101640

--- Comment #4 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-9 branch has been updated by Iain Buclaw
<ibuclaw@gcc.gnu.org>:

https://gcc.gnu.org/g:0513528fe9eae642338089a84414e99faf49cbee

commit r9-9651-g0513528fe9eae642338089a84414e99faf49cbee
Author: Iain Buclaw <ibuclaw@gdcproject.org>
Date:   Tue Jul 27 13:24:34 2021 +0200

    d: Wrong evaluation order of binary expressions (PR101640)

    The use of fold_build2 can in some cases swap the order of its operands
    if that is the more optimal thing to do.  However this breaks semantic
    guarantee of left-to-right evaluation in D.

            PR d/101640

    gcc/d/ChangeLog:

            * expr.cc (binary_op): Use build2 instead of fold_build2.

    gcc/testsuite/ChangeLog:

            * gdc.dg/pr101640.d: New test.

    (cherry picked from commit 54ec50bada94a8ff92edb04ee5216c27fa4bf942)

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

* [Bug d/101640] d: Wrong evaluation order of binary expressions
  2021-07-27 11:19 [Bug d/101640] New: d: Wrong evaluation order of binary expressions ibuclaw at gdcproject dot org
                   ` (3 preceding siblings ...)
  2021-07-28 11:57 ` cvs-commit at gcc dot gnu.org
@ 2021-07-28 12:48 ` ibuclaw at gdcproject dot org
  4 siblings, 0 replies; 6+ messages in thread
From: ibuclaw at gdcproject dot org @ 2021-07-28 12:48 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101640

Iain Buclaw <ibuclaw at gdcproject dot org> changed:

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

--- Comment #5 from Iain Buclaw <ibuclaw at gdcproject dot org> ---
Fix committed.

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

end of thread, other threads:[~2021-07-28 12:48 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-27 11:19 [Bug d/101640] New: d: Wrong evaluation order of binary expressions ibuclaw at gdcproject dot org
2021-07-28 11:19 ` [Bug d/101640] " cvs-commit at gcc dot gnu.org
2021-07-28 11:37 ` cvs-commit at gcc dot gnu.org
2021-07-28 11:50 ` cvs-commit at gcc dot gnu.org
2021-07-28 11:57 ` cvs-commit at gcc dot gnu.org
2021-07-28 12:48 ` ibuclaw at gdcproject 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).