Re: [LLVMdev] Handling of pointer difference in llvm-gcc and clang

2011-08-12 Thread Florian Merz
So it seems like we agreed that this is a problem that should be fixed. Shall I create a bug report suggesting for it? Am Friday, 12. August 2011, 09:32:11 schrieb Richard Guenther: > On Thu, Aug 11, 2011 at 10:36 PM, Joe Buck wrote: > > On Thu, Aug 11, 2011 at 1:58 PM, Joseph S. Myers > > > >

Re: [LLVMdev] Handling of pointer difference in llvm-gcc and clang

2011-08-12 Thread Richard Guenther
On Thu, Aug 11, 2011 at 10:36 PM, Joe Buck wrote: > On Thu, Aug 11, 2011 at 1:58 PM, Joseph S. Myers > wrote: >>  -ftrapv and -fwrapv should have no effect on pointer subtraction. > > Gaby writes: > >> Yes! > > Wouldn't it suffice to convert the pointers to unsigned, do an unsigned > subtraction

RE: [LLVMdev] Handling of pointer difference in llvm-gcc and clang

2011-08-11 Thread Joe Buck
On Thu, Aug 11, 2011 at 1:58 PM, Joseph S. Myers wrote: > -ftrapv and -fwrapv should have no effect on pointer subtraction. Gaby writes: > Yes! Wouldn't it suffice to convert the pointers to unsigned, do an unsigned subtraction, and then convert the result to signed? This would then guarantee

Re: [LLVMdev] Handling of pointer difference in llvm-gcc and clang

2011-08-11 Thread Gabriel Dos Reis
On Thu, Aug 11, 2011 at 1:58 PM, Joseph S. Myers wrote: >  -ftrapv and -fwrapv should have no effect on pointer subtraction. Yes! -- Gaby

Re: [LLVMdev] Handling of pointer difference in llvm-gcc and clang

2011-08-11 Thread Gabriel Dos Reis
On Thu, Aug 11, 2011 at 12:15 PM, Richard Guenther wrote: > On Thu, Aug 11, 2011 at 7:13 PM, Joe Buck wrote: >> On Thu, Aug 11, 2011 at 09:05:19AM -0700, Florian Merz wrote: >>> If I remember the standard correctly, pointer subtraction is valid if both >>> pointers point to elements of the same a

Re: [LLVMdev] Handling of pointer difference in llvm-gcc and clang

2011-08-11 Thread Joseph S. Myers
On Thu, 11 Aug 2011, Richard Guenther wrote: > int x,y; > int main () > { > char *a, *b; > __INTPTR_TYPE__ w; > if (x) > a = 0x7ffe; > else > a = 0x7fff; > if (y) > b = 0x8001; > else > b = 0x8000; > w = b - a; > return w; > } > > indeed traps with

Re: [LLVMdev] Handling of pointer difference in llvm-gcc and clang

2011-08-11 Thread Florian Merz
Am Thursday, 11. August 2011, 19:15:41 schrieb Richard Guenther: > On Thu, Aug 11, 2011 at 7:13 PM, Joe Buck wrote: > > On Thu, Aug 11, 2011 at 09:05:19AM -0700, Florian Merz wrote: > >> If I remember the standard correctly, pointer subtraction is valid if > >> both pointers point to elements of t

Re: [LLVMdev] Handling of pointer difference in llvm-gcc and clang

2011-08-11 Thread Richard Guenther
On Thu, Aug 11, 2011 at 7:13 PM, Joe Buck wrote: > On Thu, Aug 11, 2011 at 09:05:19AM -0700, Florian Merz wrote: >> If I remember the standard correctly, pointer subtraction is valid if both >> pointers point to elements of the same array or to one past the last element >> of the array. According

Re: [LLVMdev] Handling of pointer difference in llvm-gcc and clang

2011-08-11 Thread Joe Buck
On Thu, Aug 11, 2011 at 09:05:19AM -0700, Florian Merz wrote: > If I remember the standard correctly, pointer subtraction is valid if both > pointers point to elements of the same array or to one past the last element > of the array. According to this 0x8000 - 0x7FFF should be a valid >

Re: [LLVMdev] Handling of pointer difference in llvm-gcc and clang

2011-08-11 Thread Richard Guenther
. >> >> > Thanks a lot and regards, >> >  Florian >> > >> > P.S: It seems like clang does not treat this subtraction as signed. >> > >> > [1] http://baldur.iti.kit.edu/llbmc/ >> > >> > --  Weitergeleitete Nachricht  -

Re: [LLVMdev] Handling of pointer difference in llvm-gcc and clang

2011-08-11 Thread Florian Merz
urely must overflow, and the result therefore would be undefined. > Richard. > > > Thanks a lot and regards, > > Florian > > > > P.S: It seems like clang does not treat this subtraction as signed. > > > > [1] http://baldur.iti.kit.edu/llbmc/ > >

Re: Re: [LLVMdev] Handling of pointer difference in llvm-gcc and clang

2011-08-11 Thread Richard Guenther
s a lot and regards, >  Florian > > P.S: It seems like clang does not treat this subtraction as signed. > > [1] http://baldur.iti.kit.edu/llbmc/ > > ------  Weitergeleitete Nachricht  ------ > > Betreff: Re: [LLVMdev] Handling of pointer difference in llvm-gcc an

Fwd: Re: [LLVMdev] Handling of pointer difference in llvm-gcc and clang

2011-08-11 Thread Florian Merz
signed subtraction? Thanks a lot and regards, Florian P.S: It seems like clang does not treat this subtraction as signed. [1] http://baldur.iti.kit.edu/llbmc/ -- Weitergeleitete Nachricht -- Betreff: Re: [LLVMdev] Handling of pointer difference in llvm-gcc and clang Datum