public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/20689] New: strict aliasing with temporary variable never gives warnings
@ 2005-03-30  9:59 varun0005 at gmail dot com
  2005-03-30 10:07 ` [Bug c/20689] " falk at debian dot org
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: varun0005 at gmail dot com @ 2005-03-30  9:59 UTC (permalink / raw)
  To: gcc-bugs

int i;
void *p=(void *)&i;
gives strict-aliasing warning
 but
int i,*o;
o=&i;
void *p= o;
doesn't give any warning

-- 
           Summary: strict aliasing with temporary variable never gives
                    warnings
           Product: gcc
           Version: 3.3.4
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: varun0005 at gmail dot com
                CC: gcc-bugs at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20689


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug c/20689] strict aliasing with temporary variable never gives warnings
  2005-03-30  9:59 [Bug c/20689] New: strict aliasing with temporary variable never gives warnings varun0005 at gmail dot com
@ 2005-03-30 10:07 ` falk at debian dot org
  2005-03-30 12:02 ` varun0005 at gmail dot com
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: falk at debian dot org @ 2005-03-30 10:07 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From falk at debian dot org  2005-03-30 10:06 -------
I don't understand what you mean. Please provide a *complete* test case,
with the command line you use and the output you get, and an explanation
of why you want a warning.


-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |WAITING


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20689


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug c/20689] strict aliasing with temporary variable never gives warnings
  2005-03-30  9:59 [Bug c/20689] New: strict aliasing with temporary variable never gives warnings varun0005 at gmail dot com
  2005-03-30 10:07 ` [Bug c/20689] " falk at debian dot org
@ 2005-03-30 12:02 ` varun0005 at gmail dot com
  2005-03-30 12:24 ` falk at debian dot org
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: varun0005 at gmail dot com @ 2005-03-30 12:02 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From varun0005 at gmail dot com  2005-03-30 12:02 -------
I mean that since in case where you are doing "void *p=(void *)&i" then
according to strict-aliasing rules we get " warning: dereferencing type-punned
pointer will break strict-aliasing rules" , but same thing if done using a
temporary variable then why strict-aliasing warning doesn't appear.. According
to my understanding of strict aliasing if some unqualified version of pointer is
pointing to the address space(in out case void pointer pointing to int address
space) then it is violating  strict aliasing rule. So in second case also void
pointer is pointing to the int address space then why strict aliasing rules are
not violated. If ther is some error in my understanding of strict aliasing then
please inform .

-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20689


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug c/20689] strict aliasing with temporary variable never gives warnings
  2005-03-30  9:59 [Bug c/20689] New: strict aliasing with temporary variable never gives warnings varun0005 at gmail dot com
  2005-03-30 10:07 ` [Bug c/20689] " falk at debian dot org
  2005-03-30 12:02 ` varun0005 at gmail dot com
@ 2005-03-30 12:24 ` falk at debian dot org
  2005-03-30 15:46 ` pinskia at gcc dot gnu dot org
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: falk at debian dot org @ 2005-03-30 12:24 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From falk at debian dot org  2005-03-30 12:23 -------
(In reply to comment #2)
> I mean that since in case where you are doing "void *p=(void *)&i" then
> according to strict-aliasing rules we get " warning: dereferencing type-punned
> pointer will break strict-aliasing rules" 

No, you don't. Please provide a *complete* test case, with the command line
you use and the output you get.



-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20689


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug c/20689] strict aliasing with temporary variable never gives warnings
  2005-03-30  9:59 [Bug c/20689] New: strict aliasing with temporary variable never gives warnings varun0005 at gmail dot com
                   ` (2 preceding siblings ...)
  2005-03-30 12:24 ` falk at debian dot org
@ 2005-03-30 15:46 ` pinskia at gcc dot gnu dot org
  2005-03-31  5:06 ` varun0005 at gmail dot com
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-03-30 15:46 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-03-30 15:45 -------
Also this is not done because void* cannot be dereferenced.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|WAITING                     |RESOLVED
         Resolution|                            |INVALID


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20689


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug c/20689] strict aliasing with temporary variable never gives warnings
  2005-03-30  9:59 [Bug c/20689] New: strict aliasing with temporary variable never gives warnings varun0005 at gmail dot com
                   ` (3 preceding siblings ...)
  2005-03-30 15:46 ` pinskia at gcc dot gnu dot org
@ 2005-03-31  5:06 ` varun0005 at gmail dot com
  2005-03-31 10:21 ` varun0005 at gmail dot com
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: varun0005 at gmail dot com @ 2005-03-31  5:06 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From varun0005 at gmail dot com  2005-03-31 05:05 -------
please ignore previous code and consider this piece as example ... problem is
same .the exact programs are following and command line was gcc -Wall -O2
test1.c test2.c....In this why test1.c not giving warning but test2.c giving
violation of strict-aliasing warning.
//test1.c
#include <stdio.h>
#include <stdlib.h>
int main()
{ int *i;
float **q;
int **r;
i =(int *)malloc(sizeof(int));
r=&i;
q=(float **)r;
return 0;
}
//test2.c
int main(){
int *i;
float **q; 
i =(int *)malloc(sizeof(int));
q= (float **) &i;
return 0;
}

-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20689


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug c/20689] strict aliasing with temporary variable never gives warnings
  2005-03-30  9:59 [Bug c/20689] New: strict aliasing with temporary variable never gives warnings varun0005 at gmail dot com
                   ` (4 preceding siblings ...)
  2005-03-31  5:06 ` varun0005 at gmail dot com
@ 2005-03-31 10:21 ` varun0005 at gmail dot com
  2005-06-30  2:21 ` pinskia at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: varun0005 at gmail dot com @ 2005-03-31 10:21 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From varun0005 at gmail dot com  2005-03-31 10:18 -------
please ignore previous code and consider this piece as example ... problem is
same .the exact programs are following and command line was gcc -Wall -O2
test1.c test2.c....In this why test1.c not giving warning but test2.c giving
violation of strict-aliasing warning.
//test1.c
#include <stdio.h>
#include <stdlib.h>
int main()
{ int *i;
float **q;
int **r;
i =(int *)malloc(sizeof(int));
r=&i;
q=(float **)r;
return 0;
}
//test2.c
int main(){
int *i;
float **q; 
i =(int *)malloc(sizeof(int));
q= (float **) &i;
return 0;
}



-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |UNCONFIRMED
         Resolution|INVALID                     |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20689


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug c/20689] strict aliasing with temporary variable never gives warnings
  2005-03-30  9:59 [Bug c/20689] New: strict aliasing with temporary variable never gives warnings varun0005 at gmail dot com
                   ` (5 preceding siblings ...)
  2005-03-31 10:21 ` varun0005 at gmail dot com
@ 2005-06-30  2:21 ` pinskia at gcc dot gnu dot org
  2005-07-02  0:58 ` pinskia at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-06-30  2:21 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-06-30 02:20 -------
Even the example you gave in comment #6 is hard to get unless you have flow analysis in the front-end 
which I really doubt is even going to be.


-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|normal                      |enhancement
           Keywords|                            |diagnostic


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20689


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug c/20689] strict aliasing with temporary variable never gives warnings
  2005-03-30  9:59 [Bug c/20689] New: strict aliasing with temporary variable never gives warnings varun0005 at gmail dot com
                   ` (6 preceding siblings ...)
  2005-06-30  2:21 ` pinskia at gcc dot gnu dot org
@ 2005-07-02  0:58 ` pinskia at gcc dot gnu dot org
  2005-07-11 18:00 ` pinskia at gcc dot gnu dot org
  2005-07-27 23:39 ` pinskia at gcc dot gnu dot org
  9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-07-02  0:58 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-07-02 00:58 -------
*** Bug 20709 has been marked as a duplicate of this bug. ***

-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20689


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug c/20689] strict aliasing with temporary variable never gives warnings
  2005-03-30  9:59 [Bug c/20689] New: strict aliasing with temporary variable never gives warnings varun0005 at gmail dot com
                   ` (7 preceding siblings ...)
  2005-07-02  0:58 ` pinskia at gcc dot gnu dot org
@ 2005-07-11 18:00 ` pinskia at gcc dot gnu dot org
  2005-07-27 23:39 ` pinskia at gcc dot gnu dot org
  9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-07-11 18:00 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-07-11 17:58 -------
Closing as invalid based comment #7.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |WONTFIX


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20689


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug c/20689] strict aliasing with temporary variable never gives warnings
  2005-03-30  9:59 [Bug c/20689] New: strict aliasing with temporary variable never gives warnings varun0005 at gmail dot com
                   ` (8 preceding siblings ...)
  2005-07-11 18:00 ` pinskia at gcc dot gnu dot org
@ 2005-07-27 23:39 ` pinskia at gcc dot gnu dot org
  9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-07-27 23:39 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-07-27 23:39 -------
*** Bug 23106 has been marked as a duplicate of this bug. ***

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |fn_x at hotmail dot com


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20689


^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2005-07-27 23:39 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-03-30  9:59 [Bug c/20689] New: strict aliasing with temporary variable never gives warnings varun0005 at gmail dot com
2005-03-30 10:07 ` [Bug c/20689] " falk at debian dot org
2005-03-30 12:02 ` varun0005 at gmail dot com
2005-03-30 12:24 ` falk at debian dot org
2005-03-30 15:46 ` pinskia at gcc dot gnu dot org
2005-03-31  5:06 ` varun0005 at gmail dot com
2005-03-31 10:21 ` varun0005 at gmail dot com
2005-06-30  2:21 ` pinskia at gcc dot gnu dot org
2005-07-02  0:58 ` pinskia at gcc dot gnu dot org
2005-07-11 18:00 ` pinskia at gcc dot gnu dot org
2005-07-27 23:39 ` pinskia at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).