Ancestors

Toot

Written by Laria on 2024-07-16 at 19:21

Sooo, if I build a #c program on #gcc once with -O0 and once with -O2, and it outputs something different. And gcc builds it without any warnings, even with -Wall -Werror -Wextra -pedantic. And also UBSan not finding any undefined behaviors.... Assuming all that, have I found a bug in GCC? 😬

(The disassembly gdb spits out for the offending function looks kinda wrong to me, but my ASM skills are a bit rusty...)

=> View attached media

=> More informations about this toot | More toots from laria@duclaria.com

Descendants

Written by Laria on 2024-07-18 at 19:56

I now reduced this to a single ~100 lines file that does no dynamic memory allocations. I'm pretty sure I'm not doing something that is undefined behavior. Still getting different results with -O0 / -O2. Even more weirdly, the bug(?) goes away when I remove an assert that only does a simple comparison. Also goes away when I remove certain struct members that are never written or read from.

I'm pretty sure this is indeed a compiler bug 😱

Currently building GCC from source to test against that.

=> More informations about this toot | More toots from laria@duclaria.com

Written by Laria on 2024-07-18 at 20:31

Cool. I can't even do that, make check fails for MPFR 4.1.0, needed by GCC.

=> View attached media

=> More informations about this toot | More toots from laria@duclaria.com

Written by Laria on 2024-07-18 at 21:25

Bonus for compiling GCC from source: Pretty CPU graph 🌈

=> View attached media

=> More informations about this toot | More toots from laria@duclaria.com

Written by Laria on 2024-07-18 at 22:15

Still happening with GCC build from source. And actually -O1 is enough. Seems like I get to write a bug report tomorrow

=> More informations about this toot | More toots from laria@duclaria.com

Written by Laria on 2024-07-25 at 21:25

Finally wrote the #gcc bug report for this: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116098

Honestly a bit intimidating writing a bug report for such a high profile project. I really hope I haven't overlooked something super obvious 😬🤓

=> More informations about this toot | More toots from laria@duclaria.com

Written by mkretz on 2024-07-26 at 07:14

@laria 👍 I know the feeling. It gets less intimidating over time. But isn't it rewarding how the bug report comes to life right away - with information (though very technical) about the cause and possible fix?

=> More informations about this toot | More toots from mkretz@floss.social

Written by Laria on 2024-07-26 at 11:22

@mkretz yes, it really is rewarding :). Actually really impressed how quickly this got a response!

=> More informations about this toot | More toots from laria@duclaria.com

Proxy Information
Original URL
gemini://mastogem.picasoft.net/thread/112797792090672108
Status Code
Success (20)
Meta
text/gemini
Capsule Response Time
389.544206 milliseconds
Gemini-to-HTML Time
3.558637 milliseconds

This content has been proxied by September (ba2dc).