[Bug tree-optimization/114776] -Wuse-after-free analysis believes assert() but not g_assert_null()

2024-04-18 Thread alan.coopersmith at oracle dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114776

--- Comment #6 from Alan Coopersmith  ---
Thanks, I didn't realize there was a test_nonfatal_assertions path through
the g_assert that could return here.

I'll update the wording on my proposed workaround to reflect that:
https://gitlab.freedesktop.org/xorg/lib/libxmu/-/merge_requests/16

[Bug tree-optimization/114776] -Wuse-after-free analysis believes assert() but not g_assert_null()

2024-04-18 Thread alan.coopersmith at oracle dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114776

--- Comment #5 from Alan Coopersmith  ---
Created attachment 57986
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=57986=edit
Preproccessed test case

[Bug tree-optimization/114776] -Wuse-after-free analysis believes assert() but not g_assert_null()

2024-04-18 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114776

Andrew Pinski  changed:

   What|Removed |Added

 Status|WAITING |RESOLVED
 Resolution|--- |INVALID

--- Comment #4 from Andrew Pinski  ---


So g_assertion_message can actually return in one case.
https://github.com/GNOME/glib/blob/81eaabb30803b0e30edca888772f7459fa389650/glib/gtestutils.c#L3305

So yes this is a valid warning.

[Bug tree-optimization/114776] -Wuse-after-free analysis believes assert() but not g_assert_null()

2024-04-18 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114776

--- Comment #3 from Andrew Pinski  ---
Seems like g_assertion_message should have _Noreturn on it if you are compiling
for C11-C17 and [[noreturn]] for C++11+ (and C23+).

[Bug tree-optimization/114776] -Wuse-after-free analysis believes assert() but not g_assert_null()

2024-04-18 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114776

--- Comment #2 from Andrew Pinski  ---
As far as I can tell g_assertion_message does not have noreturn on it which
means this invalid.

It only has G_ANALYZER_NORETURN on it.
which is only defined to analyzer_noreturn if running under clang's analyzer.

[Bug tree-optimization/114776] -Wuse-after-free analysis believes assert() but not g_assert_null()

2024-04-18 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114776

Andrew Pinski  changed:

   What|Removed |Added

 Status|UNCONFIRMED |WAITING
   Last reconfirmed||2024-04-18
 Ever confirmed|0   |1

--- Comment #1 from Andrew Pinski  ---
Can you attach the preprocessed source?

It is almost definitely the way g_assert_null is defined.