public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/112442] New: Segfault from casting a ptr when using -O2
@ 2023-11-08 13:12 adam.andersson at elisapolystar dot com
  2023-11-08 14:16 ` [Bug c/112442] " adam.andersson at elisapolystar dot com
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: adam.andersson at elisapolystar dot com @ 2023-11-08 13:12 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112442

            Bug ID: 112442
           Summary: Segfault from casting a ptr when using -O2
           Product: gcc
           Version: 13.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: adam.andersson at elisapolystar dot com
  Target Milestone: ---

Created attachment 56532
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=56532&action=edit
Small testprogram that reproduces the issue

I have attached a simple program that segfaults when compiling with GCC 13 and
-O2

Compiled with: gcc -v -save-temps -O2 gcc-segfault.c

How to reproduce:
$ gcc -O2 a-gcc-segfault.i -o test && ./test
Segmentation fault (core dumped)


This does not happen in GCC 12 or earlier, or if I use -O1 or no optimization.
Also doesnt happen if I remove the cast to unsigned char*, or if I inline the
test-function. 


My system:
Linux adam1 6.5.9-arch2-1 #1 SMP PREEMPT_DYNAMIC Thu, 26 Oct 2023 00:52:20
+0000 x86_64 GNU/Linux
gcc version 13.2.1 20230801 (GCC)

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2023-11-09 16:18 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-08 13:12 [Bug c/112442] New: Segfault from casting a ptr when using -O2 adam.andersson at elisapolystar dot com
2023-11-08 14:16 ` [Bug c/112442] " adam.andersson at elisapolystar dot com
2023-11-08 14:24 ` redi at gcc dot gnu.org
2023-11-08 14:33 ` pinskia at gcc dot gnu.org
2023-11-08 14:42 ` adam.andersson at elisapolystar dot com
2023-11-08 14:54 ` schwab@linux-m68k.org
2023-11-08 15:32 ` xry111 at gcc dot gnu.org
2023-11-08 15:35 ` xry111 at gcc dot gnu.org
2023-11-08 16:15 ` redi at gcc dot gnu.org
2023-11-08 17:43 ` adam.andersson at elisapolystar dot com
2023-11-09 16:18 ` xry111 at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).