Re: Tricky(?) aliasing question.

2007-01-11 Thread Sergei Organov
Ian Lance Taylor [EMAIL PROTECTED] writes: Sergei Organov [EMAIL PROTECTED] writes: Below are two example functions foo() and boo(), that I think both are valid from the POV of strict aliasing rules. GCC 4.2 either warns about both (with -Wstrict-aliasing=2) or doesn't warn about any (with

Re: Tricky(?) aliasing question.

2007-01-11 Thread Andrew Haley
Sergei Organov writes: Ian Lance Taylor [EMAIL PROTECTED] writes: Sergei Organov [EMAIL PROTECTED] writes: $ cat alias.c typedef struct { int i; } S; int i; int foo() { S const sc = { 10 }; i = 20; // Accessing object 'i' of type 'int' through 'S'

Re: Tricky(?) aliasing question.

2007-01-11 Thread Sergei Organov
Andrew Haley [EMAIL PROTECTED] writes: Sergei Organov writes: Ian Lance Taylor [EMAIL PROTECTED] writes: Sergei Organov [EMAIL PROTECTED] writes: $ cat alias.c typedef struct { int i; } S; int i; int foo() { S const sc = { 10 }; i = 20;

Re: Tricky(?) aliasing question.

2007-01-11 Thread Andrew Haley
Sergei Organov writes: Andrew Haley [EMAIL PROTECTED] writes: Sergei Organov writes: Ian Lance Taylor [EMAIL PROTECTED] writes: Sergei Organov [EMAIL PROTECTED] writes: int float_as_int() { h1.f = 1; H0 h0 = *(H0*)h1.f; // Should be OK? No, it is

Re: Tricky(?) aliasing question.

2007-01-11 Thread Sergei Organov
Andrew Haley [EMAIL PROTECTED] writes: Sergei Organov writes: Andrew Haley [EMAIL PROTECTED] writes: Sergei Organov writes: Ian Lance Taylor [EMAIL PROTECTED] writes: Sergei Organov [EMAIL PROTECTED] writes: int float_as_int() { h1.f = 1;

Re: Tricky(?) aliasing question.

2007-01-11 Thread Andrew Haley
Sergei Organov writes: Andrew Haley [EMAIL PROTECTED] writes: Sergei Organov writes: Andrew Haley [EMAIL PROTECTED] writes: Sergei Organov writes: Ian Lance Taylor [EMAIL PROTECTED] writes: Sergei Organov [EMAIL PROTECTED] writes: int

Re: Tricky(?) aliasing question.

2007-01-11 Thread Sergei Organov
Andrew Haley [EMAIL PROTECTED] writes: Sergei Organov writes: Andrew Haley [EMAIL PROTECTED] writes: Sergei Organov writes: Andrew Haley [EMAIL PROTECTED] writes: Sergei Organov writes: Ian Lance Taylor [EMAIL PROTECTED] writes: Sergei Organov

Re: Tricky(?) aliasing question.

2007-01-11 Thread Andrew Haley
Sergei Organov writes: If we come back to strict aliasing rules, then I will have to refer once again to already cited place in the standard that says that I'm permitted to access an object not only through a compatible type, but also through a structure containing a field of compatible

Re: Tricky(?) aliasing question.

2007-01-11 Thread Mike Stump
On Jan 11, 2007, at 6:30 AM, Sergei Organov wrote: So h1.f is not an object? If it is not, it brings us back to the validity of my boo() function from the initial post, for which 2 persons (3 including me) thought it's OK: Would be nice for you to raise the issue directly with the C

Re: Tricky(?) aliasing question.

2007-01-11 Thread Sergei Organov
Andrew Haley [EMAIL PROTECTED] writes: Sergei Organov writes: If we come back to strict aliasing rules, then I will have to refer once again to already cited place in the standard that says that I'm permitted to access an object not only through a compatible type, but also through a

Re: Tricky(?) aliasing question.

2007-01-11 Thread Sergei Organov
Mike Stump [EMAIL PROTECTED] writes: On Jan 11, 2007, at 6:30 AM, Sergei Organov wrote: So h1.f is not an object? If it is not, it brings us back to the validity of my boo() function from the initial post, for which 2 persons (3 including me) thought it's OK: Would be nice for you to raise

Re: Tricky(?) aliasing question.

2007-01-11 Thread Andrew Haley
Sergei Organov writes: Andrew Haley [EMAIL PROTECTED] writes: Sergei Organov writes: If we come back to strict aliasing rules, then I will have to refer once again to already cited place in the standard that says that I'm permitted to access an object not only through a

Re: Tricky(?) aliasing question.

2007-01-11 Thread Andrew Haley
Sergei Organov writes: BTW, I've tried once to raise similar aliasing question in comp.std.c++. The result was that somebody started to talk about validity of pointers conversions that IMHO has nothing to do with strict aliasing, It's the same issue. and the discussion died. It is

Re: Tricky(?) aliasing question.

2007-01-11 Thread Silvius Rus
Sergei Organov wrote: Ian Lance Taylor [EMAIL PROTECTED] writes: Sergei Organov [EMAIL PROTECTED] writes: Below are two example functions foo() and boo(), that I think both are valid from the POV of strict aliasing rules. GCC 4.2 either warns about both (with -Wstrict-aliasing=2) or

Re: Tricky(?) aliasing question.

2007-01-11 Thread Sergei Organov
Silvius Rus [EMAIL PROTECTED] writes: [...] I am about to submit a patch that implements -Wstrict-aliasing in the backend based on flow-sensitive points-to information, which is computed by analyzing the entire source of each function. It is not perfect (the problem is undecidable), but it

Re: Tricky(?) aliasing question.

2007-01-11 Thread Sergei Organov
Andrew Haley [EMAIL PROTECTED] writes: Sergei Organov writes: BTW, I've tried once to raise similar aliasing question in comp.std.c++. The result was that somebody started to talk about validity of pointers conversions that IMHO has nothing to do with strict aliasing, It's the

Re: Tricky(?) aliasing question.

2007-01-11 Thread Sergei Organov
Andrew Haley [EMAIL PROTECTED] writes: Sergei Organov writes: Andrew Haley [EMAIL PROTECTED] writes: Sergei Organov writes: If we come back to strict aliasing rules, then I will have to refer once again to already cited place in the standard that says that I'm

Re: Tricky(?) aliasing question.

2007-01-11 Thread Silvius Rus
Andrew Pinski wrote: Third, it only checks C programs (and not C++). This has not been true for some time now (at least developmental wise). -- Pinski Oops, had not noticed that. Forget third argument then. Silvius

Re: Tricky(?) aliasing question.

2007-01-10 Thread Ian Lance Taylor
Sergei Organov [EMAIL PROTECTED] writes: Below are two example functions foo() and boo(), that I think both are valid from the POV of strict aliasing rules. GCC 4.2 either warns about both (with -Wstrict-aliasing=2) or doesn't warn about any (with -Wstrict-aliasing), and generates the

Re: Tricky(?) aliasing question.

2007-01-10 Thread Daniel Berlin
It is possible that somebody else will disagree with me. FWIW, our currently aliasing set implementation agrees with you on both counts :)