gcc 3.2.3 x64 negative indexes
Hi. I am using a slightly modified gcc 3.2.3 for x86_64 and for this code: int fff(char *x) { return (x[-1]); } It is generating: .globl fff fff: .LFB2: movl$4294967295, %eax movsbl (%rax,%rcx),%eax ret My understanding is that that move of -1 into eax does NOT sign-extend, and thus results in a very high index, which causes a crash. I may have stuffed something up myself. Anyone know which code governs this behavior? Thanks. Paul.
Re: gcc 3.2.3 x64 negative indexes
On Wed, Feb 07, 2024 at 11:02:51PM +0800, Paul Edwards via Gcc wrote: > I am using a slightly modified gcc 3.2.3 for x86_64 and for this code: Don't, gcc 3.2.3 is not supported for more than 20 years already. > int fff(char *x) > { > return (x[-1]); > } > > > It is generating: > > .globl fff > fff: > .LFB2: > movl$4294967295, %eax > movsbl (%rax,%rcx),%eax That said, I can't reproduce it and get movsbl -1(%rdi),%eax ret from 3.2.3. Jakub