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

            Bug ID: 123960
           Summary: Incorrect pointer address calculation on x64.
           Product: gcc
           Version: 15.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: sz.tarnowski at gmail dot com
  Target Milestone: ---

Created attachment 63577
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=63577&action=edit
example code

Following code leads to Segmentation fault due to incorrect calculation during
operation on pointer.

ptr = memory + -((unsigned int)*ptr);
Works perfect when improved to:
ptr = memory -((unsigned int)*ptr);

This code was generated by Ghidra as part of assembly code intepretation.
The result is unexpected "roll-over" on 32 bit (lowest bit of high 32b word).
Sample result of attached example.

0x55f13fb78310 allocated
0x55f13fb78311 incremented
0x55f23fb78310 after magic

Reply via email to