https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112442
--- Comment #10 from Xi Ruoyao ---
(In reply to Adam Andersson from comment #9)
> I was sure I had tried -fno-strict-aliasing without any difference, but I
> guessed I messed up somehow. Sorry about that.
>
> Still, is it not strange that -Wall
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112442
--- Comment #9 from Adam Andersson ---
I was sure I had tried -fno-strict-aliasing without any difference, but I
guessed I messed up somehow. Sorry about that.
Still, is it not strange that -Wall doesn't generate a warning about this then?
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112442
--- Comment #8 from Jonathan Wakely ---
The aliasing doesn't happen when writing to the array, it's when reading a
char* value from an object of type unsigned char*.
If you just passed the unsigned char* to memcpy instead of *(char**)&ptr it
wo
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112442
--- Comment #7 from Xi Ruoyao ---
Note that in the "new bug" page, there is a red banner saying:
Before reporting that GCC compiles your code incorrectly, compile it with gcc
-Wall -Wextra and see whether this shows anything wrong with your cod
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112442
Xi Ruoyao changed:
What|Removed |Added
Resolution|--- |INVALID
Status|UNCONFIRMED
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112442
--- Comment #5 from Andreas Schwab ---
warning: dereferencing type-punned pointer will break strict-aliasing rules
[-Wstrict-aliasing]
15 | test((char **)&ptr, "test!");
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112442
--- Comment #4 from Adam Andersson ---
(In reply to Andrew Pinski from comment #3)
> I am not 100% sure but there seems like some kind of aliasing issue going on.
>
> Basically you have a pointer to an `unsigned char` but writing it via a
> poi
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112442
--- Comment #3 from Andrew Pinski ---
I am not 100% sure but there seems like some kind of aliasing issue going on.
Basically you have a pointer to an `unsigned char` but writing it via a pointer
to `char`.
Yes writing to a type via `char` woul
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112442
--- Comment #2 from Jonathan Wakely ---
Looks like it doesn't always segfault, but the contents of the tmp buffer are
incorrect (which might segfault, or might fail to print "test!").
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112442
--- Comment #1 from Adam Andersson ---
Disregard my comment about it working GCC 12. In gcc version 12.3.0 (GCC) it
does not work either.
10 matches
Mail list logo