Hi,

On 4 Jan 2025, at 16:13, Simon Martin wrote:

> The invalid case in this PR trips on an assertion in
> build_class_member_access_expr that build_base_path would never return
> an error_mark_node, which is actually incorrect if the object involves 
> a
> tree with an error_mark_node DECL_INITIAL, like here.
>
> This patch simply removes the assertion, even though it has been here
> for 22+ years (r0-44513-g50ad96428042fa). An alternative would be to
> assert that object != error_mark_node || seen_error (), but that'd be
> virtually not asserting anything IMO.
>
> Successfully tested on x86_64-pc-linux-gnu.
Friendly ping.

Thanks! Simon
>
>       PR c++/118225
>
> gcc/cp/ChangeLog:
>
>       * typeck.cc (build_class_member_access_expr): Remove incorrect
>       gcc_assert.
>
> gcc/testsuite/ChangeLog:
>
>       * g++.dg/cpp0x/constexpr-ice21.C: New test.
>
> ---
>  gcc/cp/typeck.cc                             |  3 ---
>  gcc/testsuite/g++.dg/cpp0x/constexpr-ice21.C | 17 +++++++++++++++++
>  2 files changed, 17 insertions(+), 3 deletions(-)
>  create mode 100644 gcc/testsuite/g++.dg/cpp0x/constexpr-ice21.C
>
> diff --git a/gcc/cp/typeck.cc b/gcc/cp/typeck.cc
> index 1f9a74166f4..14912254c9c 100644
> --- a/gcc/cp/typeck.cc
> +++ b/gcc/cp/typeck.cc
> @@ -2978,9 +2978,6 @@ build_class_member_access_expr (cp_expr object, 
> tree member,
>         /* Convert to the base.  */
>         object = build_base_path (PLUS_EXPR, object, binfo,
>                                   /*nonnull=*/1, complain);
> -       /* If we found the base successfully then we should be able
> -          to convert to it successfully.  */
> -       gcc_assert (object != error_mark_node);
>       }
>
>        /* If MEMBER is from an anonymous aggregate, we have converted
> diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-ice21.C 
> b/gcc/testsuite/g++.dg/cpp0x/constexpr-ice21.C
> new file mode 100644
> index 00000000000..46273654f24
> --- /dev/null
> +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-ice21.C
> @@ -0,0 +1,17 @@
> +// PR c++/118225
> +// { dg-do "compile" { target c++11} }
> +
> +struct NoMut1 { int a, b; };
> +struct NoMut3 : virtual NoMut1 {
> +  constexpr NoMut3(int a, int b) // { dg-error "virtual base" "" { 
> target c++23 } }
> +    : NoMut1{a, b}
> +  {} // { dg-error "virtual base" }
> +};
> +void mutable_subobjects() {
> +  constexpr NoMut3 nm3 = {1, 2}; // { dg-error "call to non" }
> +  struct A {
> +    void f() {
> +      static_assert(nm3.a == 1, ""); // { dg-error "local variable" }
> +    }
> +  };
> +}
> -- 
> 2.44.0

Reply via email to