Re: old aliasing bug: fixed?

2010-10-20 Thread Richard Guenther
On Wed, Oct 20, 2010 at 10:29 AM, Albert Cahalan wrote: > On Thu, Sep 30, 2010 at 5:39 AM, Richard Guenther > wrote: >> On Thu, Sep 30, 2010 at 9:54 AM, Albert Cahalan wrote: >>> int weird(float *fp){ >>>        // access an int as an int (see caller), >>>        // so not an aliasing violation

Re: old aliasing bug: fixed?

2010-10-20 Thread Albert Cahalan
On Thu, Sep 30, 2010 at 5:39 AM, Richard Guenther wrote: > On Thu, Sep 30, 2010 at 9:54 AM, Albert Cahalan wrote: >> int weird(float *fp){ >>        // access an int as an int (see caller), >>        // so not an aliasing violation >>        return *(int*)fp; >> } >> int main(int argc, char *argv

Re: old aliasing bug: fixed?

2010-09-30 Thread Richard Guenther
On Thu, Sep 30, 2010 at 9:54 AM, Albert Cahalan wrote: > int weird(float *fp){ >        // access an int as an int (see caller), >        // so not an aliasing violation >        return *(int*)fp; > } > int main(int argc, char *argv[]){ >        return weird((float*)&argc); > } > > I just tried th

old aliasing bug: fixed?

2010-09-30 Thread Albert Cahalan
int weird(float *fp){ // access an int as an int (see caller), // so not an aliasing violation return *(int*)fp; } int main(int argc, char *argv[]){ return weird((float*)&argc); } I just tried this code with gcc 4.4.5 on 32-bit powerpc using -O2 -W -Wall. Assembly c

Re: Aliasing bug

2009-07-02 Thread Richard Guenther
On Thu, Jul 2, 2009 at 3:46 PM, Andrew Stubbs wrote: > On 02/07/09 14:34, Richard Guenther wrote: >> >> No, that's invalid.  You would have to do >> >> extern union { >>   void *foo; >>   short *bar; >> }; >> >> using the union for the double-indirect pointer doesn't help.  Or >> simply use memcpy

Re: Aliasing bug

2009-07-02 Thread Andrew Haley
Andrew Stubbs wrote: > On 02/07/09 14:34, Richard Guenther wrote: >> No, that's invalid. You would have to do >> >> extern union { >>void *foo; >>short *bar; >> }; >> >> using the union for the double-indirect pointer doesn't help. Or >> simply use memcpy to store to foo. > > Ah, I did n

Re: Aliasing bug

2009-07-02 Thread Andrew Stubbs
On 02/07/09 14:34, Richard Guenther wrote: No, that's invalid. You would have to do extern union { void *foo; short *bar; }; using the union for the double-indirect pointer doesn't help. Or simply use memcpy to store to foo. Ah, I did not know that. I still don't understand how a refe

Re: Aliasing bug

2009-07-02 Thread Richard Guenther
On Thu, Jul 2, 2009 at 3:29 PM, Andrew Stubbs wrote: > On 02/07/09 14:26, Richard Guenther wrote: >> >> You are writing to memory of type void * via an lvalue of type short *. > > Yes, there is type punning there, but that should work, shouldn't it? No, that's invalid. You would have to do exter

Re: Aliasing bug

2009-07-02 Thread Andrew Stubbs
On 02/07/09 14:26, Richard Guenther wrote: You are writing to memory of type void * via an lvalue of type short *. Yes, there is type punning there, but that should work, shouldn't it? This code is distilled from some glibc code I'm having trouble with. Andrew

Re: Aliasing bug

2009-07-02 Thread Richard Guenther
On Thu, Jul 2, 2009 at 3:21 PM, Andrew Stubbs wrote: > Hi all, > > I'm fairly sure I have found an aliasing bug in GCC, although I could be > wrong. I've reproduced it in both 4.4 and mainline. > > Consider this testcase, aliasing.c: > >    extern void *foo; >

Aliasing bug

2009-07-02 Thread Andrew Stubbs
Hi all, I'm fairly sure I have found an aliasing bug in GCC, although I could be wrong. I've reproduced it in both 4.4 and mainline. Consider this testcase, aliasing.c: extern void *foo; extern inline short ** f1 (void) { union {