On Tue, Apr 29, 2025 at 1:26 AM <[email protected]> wrote:
>
> From: Arthur Cohen <[email protected]>
>
> Hi everyone,
>
> We noticed inconsistent errors when running name-resolution 2.0 on
> certain files, where an invalid error was triggered and the message was
> from the `funny_ice` error finalizer function we had added as an easter
> egg. We realized yesterday that the undefined value was actually our
> `funny_error` boolean, which is supposed to be set only when resolving
> specific easter eggs `AST::IdentifierExpr`s.
>
> Since `funny_error` is a boolean, it does not get default-initialized in
> the constructor of `Late` - which this patch corrects.
>
> I will be pushing it to trunk directly, but this email specifically
> concerns its port into 15.2.
I am not sure if using NSDMI might be a better style here than doing
it in the constructor.
That is:
```
diff --git a/gcc/rust/resolve/rust-late-name-resolver-2.0.h
b/gcc/rust/resolve/rust-late-name-resolver-2.0.h
index 171d9bfe0f6..2f93981b0d7 100644
--- a/gcc/rust/resolve/rust-late-name-resolver-2.0.h
+++ b/gcc/rust/resolve/rust-late-name-resolver-2.0.h
@@ -76,7 +76,7 @@ private:
/* Setup Rust's builtin types (u8, i32, !...) in the resolver */
void setup_builtin_types ();
- bool funny_error;
+ bool funny_error = false;
};
// TODO: Add missing mappings and data structures
```
Thanks,
Andrew
>
> Thanks a lot to Marc Poulhiès and Owen Avery for their help in
> discovering and fixing this.
>
> Best,
>
> Arthur
>
> gcc/rust/ChangeLog:
>
> * resolve/rust-late-name-resolver-2.0.cc (Late::Late): False
> initialize the
> funny_error field.
> ---
> gcc/rust/resolve/rust-late-name-resolver-2.0.cc | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/gcc/rust/resolve/rust-late-name-resolver-2.0.cc
> b/gcc/rust/resolve/rust-late-name-resolver-2.0.cc
> index 5f215db0a72..f46f9e7dd3e 100644
> --- a/gcc/rust/resolve/rust-late-name-resolver-2.0.cc
> +++ b/gcc/rust/resolve/rust-late-name-resolver-2.0.cc
> @@ -33,7 +33,9 @@
> namespace Rust {
> namespace Resolver2_0 {
>
> -Late::Late (NameResolutionContext &ctx) : DefaultResolver (ctx) {}
> +Late::Late (NameResolutionContext &ctx)
> + : DefaultResolver (ctx), funny_error (false)
> +{}
>
> static NodeId
> next_node_id ()
> --
> 2.49.0
>