[Bug tree-optimization/83129] New: calloc zero initialization is not taken into account by gcc
denis.campredon at gmail dot com
gcc-bugzilla@gcc.gnu.org
Thu Nov 23 13:39:00 GMT 2017
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83129
Bug ID: 83129
Summary: calloc zero initialization is not taken into account
by gcc
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: denis.campredon at gmail dot com
Target Milestone: ---
It seems that GCC does not know that calloc initialize the memory to zero.
The the following functions could be optimized to the same assemble, but only
f3 is optimized to:
xor eax, eax
ret
--------------
int f1() {
char * i = __builtin_calloc(1, 1);
return *i;
}
int f2() {
struct s{int i;}* a = __builtin_calloc(1, sizeof(*a));
return a->i;
}
int f3() {
char * i = (char*)__builtin_calloc(1, 1);
i[0] = 0;
return *i;
}
--------------
More information about the Gcc-bugs
mailing list