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

--- Comment #5 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Simon Martin <simar...@gcc.gnu.org>:

https://gcc.gnu.org/g:49058fecbfd09a3354064e7d695b4a1056ce7547

commit r15-1768-g49058fecbfd09a3354064e7d695b4a1056ce7547
Author: Simon Martin <si...@nasilyan.com>
Date:   Tue Jun 11 11:44:28 2024 +0200

    c++: Relax too strict assert in stabilize_expr [PR111160]

    The case in the ticket is an ICE on invalid due to an assert in
stabilize_expr,
    but the underlying issue can actually trigger on this *valid* code:

    === cut here ===
    struct TheClass {
      TheClass() {}
      TheClass(volatile TheClass& t) {}
      TheClass operator=(volatile TheClass& t) volatile { return t; }
    };
    void the_func() {
      volatile TheClass x, y, z;
      (false ? x : y) = z;
    }
    === cut here ===

    The problem is that stabilize_expr asserts that it returns an expression
    without TREE_SIDE_EFFECTS, which can't be if the involved type is volatile.

    This patch relaxes the assert to accept having TREE_THIS_VOLATILE on the
    returned expression.

    Successfully tested on x86_64-pc-linux-gnu.

            PR c++/111160

    gcc/cp/ChangeLog:

            * tree.cc (stabilize_expr): Stabilized expressions can have
            TREE_SIDE_EFFECTS if they're volatile.

    gcc/testsuite/ChangeLog:

            * g++.dg/overload/error8.C: New test.
            * g++.dg/overload/volatile2.C: New test.
  • [Bug c++/111160] [11/12/13/14/1... cvs-commit at gcc dot gnu.org via Gcc-bugs

Reply via email to