[Bug tree-optimization/124837] [16 regression] glib miscompiled since r16-2443-g44b24b62a44e62
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=124837 --- Comment #7 from Drea Pinski --- commit 49bfa7b9cf in glib caused the issue: ``` commit 49bfa7b9cf8b16f7f6a5b1db565575d61a37100f Author: Christian Hergert Date: Fri Sep 20 12:45:30 2024 -0700 gvarianttype: mark const functions as such These functions only rely on their input parameter and no globals, thus are candidates for sub-expression elimination. ``` They read the documentation wrong. They rely on their input argument but also the memory that the argument provides. That is pure.
[Bug tree-optimization/124837] [16 regression] glib miscompiled since r16-2443-g44b24b62a44e62
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=124837 Drea Pinski changed: What|Removed |Added Resolution|--- |MOVED Status|WAITING |RESOLVED --- Comment #6 from Drea Pinski --- Yes const here is incorrect. pure is the correct attribute to be used.
[Bug tree-optimization/124837] [16 regression] glib miscompiled since r16-2443-g44b24b62a44e62
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=124837 --- Comment #5 from Sam James --- pure works indeed. I always forget pure is the more relaxed one.
[Bug tree-optimization/124837] [16 regression] glib miscompiled since r16-2443-g44b24b62a44e62
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=124837 --- Comment #4 from Drea Pinski --- >From the documentation: The pure attribute imposes similar but looser restrictions on a function’s definition than the const attribute: pure allows the function to read any non-volatile memory, even if it changes in between successive invocations of the function. https://gcc.gnu.org/onlinedocs/gcc-15.2.0/gcc/Common-Function-Attributes.html#index-pure-function-attribute
[Bug tree-optimization/124837] [16 regression] glib miscompiled since r16-2443-g44b24b62a44e62
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=124837 Drea Pinski changed: What|Removed |Added Resolution|INVALID |--- Last reconfirmed||2026-04-10 Status|RESOLVED|WAITING Ever confirmed|0 |1 --- Comment #3 from Drea Pinski --- Does replacing const with pure work? As I mentioned const can only act on the value of the arguments and cant read memory locations (except read only ones). While pure can read memory.
[Bug tree-optimization/124837] [16 regression] glib miscompiled since r16-2443-g44b24b62a44e62
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=124837 Drea Pinski changed: What|Removed |Added Resolution|--- |INVALID Status|UNCONFIRMED |RESOLVED --- Comment #2 from Drea Pinski --- Const functions cant read memory. Only pure can.
[Bug tree-optimization/124837] [16 regression] glib miscompiled since r16-2443-g44b24b62a44e62
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=124837 --- Comment #1 from Drea Pinski --- g_variant_type_string_is_valid being marked as const might be ok, but it has a write but that is all local. It is definitely related to the issue here i think.
[Bug tree-optimization/124837] [16 regression] glib miscompiled since r16-2443-g44b24b62a44e62
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=124837 Sam James changed: What|Removed |Added Keywords||wrong-code Target Milestone|--- |16.0
