[Bug tree-optimization/39343] New: [4.4 Regression] Wrong result for __builtin_object_size (x, 1)
jakub at gcc dot gnu dot org
gcc-bugzilla@gcc.gnu.org
Mon Mar 2 12:36:00 GMT 2009
extern inline __attribute__ ((__always_inline__)) int
foo (char *dest)
{
return __builtin_object_size (dest, 1);
}
struct S
{
union
{
struct { int a, b; char c, d; } f;
struct { struct { int a, b; char c, d[255]; } e; } g;
} u;
};
int
main (void)
{
struct S s;
return foo (s.u.g.e.d) < 255;
}
fails since:
2008-08-13 Richard Guenther <rguenther@suse.de>
* tree.h (maybe_fold_offset_to_address): Declare.
* tree-ssa-ccp.c (surely_varying_stmt_p): Fix typo in last commit.
(ccp_fold): Handle pointer conversions the same as fold_stmt.
Likewise for POINTER_PLUS_EXPR.
(maybe_fold_offset_to_reference): Enable disabled code.
(maybe_fold_offset_to_address): New function.
(fold_stmt_r): Use it.
(fold_gimple_assign): Likewise.
* gimplify.c (gimplify_conversion): Use maybe_fold_offset_to_address.
(gimplify_expr): Likewise.
During gimplification foo ((char *) &s.u.g.e.d) is changed into:
foo (&s.u.f.d), where the former has __builtin_object_size (x, 1) 255, while
the latter just 1.
--
Summary: [4.4 Regression] Wrong result for __builtin_object_size
(x, 1)
Product: gcc
Version: 4.4.0
Status: UNCONFIRMED
Keywords: wrong-code
Severity: normal
Priority: P3
Component: tree-optimization
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: jakub at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39343
More information about the Gcc-bugs
mailing list