https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119314
--- Comment #4 from Novel <root at hsnovel dot net> --- (In reply to Andrew Pinski from comment #1) > >The code is a part of a much larger proprietary codebase, so it's not > >possible for me to share the exact code that reproduces it. I am writing > >this report to inform you, as I unfortunutely I cannot share the code. > > > And there is not much we can do without a testcase sorry. I know, I just wanted to report it regardless. Tought it could help in some way. (In reply to Andrew Pinski from comment #2) > See https://gcc.gnu.org/bugs/#need > > Also try using -fsanitize=address,undefined and fixing all of the issues > that it reports if any. I will do it when I get back to the working enviroment.(In reply to Andrew Pinski from comment #3) > Before `DEBUG_LOG_INFO("2 Data %p\n", dest.Data);` > is there any calls before hand? Like say to memcpy? or anything that might > have the nonnull attribute on it and uses dest.Data? > > Note memcpy before C23 was undefined (even if the length was 0) to pass a > null pointer to it. > > Does -fno-delete-null-pointer-checks if the issue you are running into? If > so there is most likely a what I described, `-fsanitize=undefined` should > catch that at runtime. No there isn't any call before that touches the variable dest, or anything that has an attribute nonnull. dest also is an argument to the function, and this function doesn't get called in anywhere in the source code. This program is a shared library, and it returns the address of the function in a function that is exported. I did not specify any attribute or logic that might make the compiler assume what dest.Data can be. It's not even accessed in any way before and after the snipped I showed. It's a parameter to a function that isn't even called anywhere in the entire project. But this bug does indeed happen only on release builds. Debug builds work just fine. If the compiler can determine that dest.Data is somehow non null, I can tell that there is clearly a bug, unless it's some super agressive compiler optimization. I will test the sanitizer as soon as I get back the working place, I will report back when I do.