https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68801
Bug ID: 68801
Summary: __builtin_object_size multiple objects ptr size issue
when adding/removing printf()
Product: gcc
Version: 4.8.2
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: derrick at ca dot ibm.com
Target Milestone: ---
As following code shows, if adding printf("OK\n") and printf("NOK\n") in
function test02(), then the result is as expected: t3=0, return 0
if comment printf("OK\n") and printf("NOK\n") in function test02(), then the
result is : t3=1, return 1.
Is this a backend issue of GCC?
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int test02(int i)
{
char a2[5];
char b2[6];
char *p2;
if (i>0)
p2=a2;
else
p2=b2;
if ((__builtin_object_size (p2, 0) == 6) && (__builtin_object_size (p2, 1)
== 6) && (__builtin_object_size (p2, 2) == 5) && (__builtin_object_size (p2,
3)== 5))
{
//printf ("OK\n");
return 0;
}
else
{
//printf ("NOK\n");
return 1;
}
}
int main()
{
int t2=1;
int t3=test02(t2);
printf ("t3=%d\n", t3);
//if (!test02(t2))
if (!t3)
return 0;
else
return 1;
}