[Bug c/20709] New: strict aliasing warning with float pointer pointing to int pointer
varun0005 at gmail dot com
gcc-bugzilla@gcc.gnu.org
Fri Apr 1 05:43:00 GMT 2005
since in case where you are doing "float **q=(float **)&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 then it is violating strict aliasing rule. So in
second case also float ** 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 .
.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;
}
--
Summary: strict aliasing warning with float pointer pointing to
int pointer
Product: gcc
Version: 3.3.4
Status: UNCONFIRMED
Severity: critical
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=20709
More information about the Gcc-bugs
mailing list