You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
The reason will be displayed to describe this comment to others. Learn more.
It fixes what I believe to be a bug in GCC. Even though you'd think this should not change anything, it does actually spit out different assembly for whatever reason:
Bad:
Good:
You can see in the bad one the value from array_pop isn't stored in a temporary to be later freed (array_delete), it's calling free on an earlier stack variable thus freeing an invalid pointer (garbage data)
Note: This only happens in gcc, and only with -Os, clang is totally fine and -O0-3 in gcc as well
27afeb0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you explain what this fixes?
27afeb0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It fixes what I believe to be a bug in GCC. Even though you'd think this should not change anything, it does actually spit out different assembly for whatever reason:
Bad:
Good:
You can see in the bad one the value from array_pop isn't stored in a temporary to be later freed (array_delete), it's calling free on an earlier stack variable thus freeing an invalid pointer (garbage data)
Note: This only happens in gcc, and only with
-Os
, clang is totally fine and-O0-3
in gcc as well