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 joe.b...@synopsys.com wrote: On Thu, Aug 11, 2011 at 1:58 PM, Joseph S. Myers jos...@codesourcery.com wrote:  -ftrapv and -fwrapv should have no effect on pointer subtraction. Gaby writes: Yes! Wouldn't it suffice to convert the pointers to

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 joe.b...@synopsys.com wrote: On Thu, Aug 11, 2011 at 1:58 PM, Joseph

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

2011-08-11 Thread Florian Merz
Dear gcc developers, this is about an issue that popped up in a verification project [1] based on LLVM, but it seems to be already present in the gimple code, before llvm-gcc transforms the gimple code to LLVM-IR. In short: Calculating the difference of two pointers seems to be treated by gcc

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

2011-08-11 Thread Richard Guenther
On Thu, Aug 11, 2011 at 5:15 PM, Florian Merz florian.m...@kit.edu wrote: Dear gcc developers, this is about an issue that popped up in a verification project [1] based on LLVM, but it seems to be already present in the gimple code, before llvm-gcc transforms the gimple code to LLVM-IR. In

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

2011-08-11 Thread Florian Merz
Thanks for your reply Richard, but I'm not satisfied with your answer, yet. :-) If I'm right, then the problem I'm refering to doesn't require large objects. See below for more. Am Thursday, 11. August 2011, 17:48:26 schrieb Richard Guenther: On Thu, Aug 11, 2011 at 5:15 PM, Florian Merz

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

2011-08-11 Thread Richard Guenther
On Thu, Aug 11, 2011 at 6:05 PM, Florian Merz florian.m...@kit.edu wrote: Thanks for your reply Richard, but I'm not satisfied with your answer, yet. :-) If I'm right, then the problem I'm refering to doesn't require large objects. See below for more. Am Thursday, 11. August 2011, 17:48:26

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
On Thu, Aug 11, 2011 at 7:13 PM, Joe Buck joe.b...@synopsys.com 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

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 joe.b...@synopsys.com 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

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 -ftrapv for me

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 richard.guent...@gmail.com wrote: On Thu, Aug 11, 2011 at 7:13 PM, Joe Buck joe.b...@synopsys.com 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

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 jos...@codesourcery.com 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 Joe Buck
On Thu, Aug 11, 2011 at 1:58 PM, Joseph S. Myers jos...@codesourcery.com 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?