public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/39343]  New: [4.4 Regression] Wrong result for __builtin_object_size (x, 1)
@ 2009-03-02 12:36 jakub at gcc dot gnu dot org
  2009-03-02 12:38 ` [Bug tree-optimization/39343] " jakub at gcc dot gnu dot org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: jakub at gcc dot gnu dot org @ 2009-03-02 12:36 UTC (permalink / raw)
  To: gcc-bugs

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


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

end of thread, other threads:[~2009-03-03 11:30 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-03-02 12:36 [Bug tree-optimization/39343] New: [4.4 Regression] Wrong result for __builtin_object_size (x, 1) jakub at gcc dot gnu dot org
2009-03-02 12:38 ` [Bug tree-optimization/39343] " jakub at gcc dot gnu dot org
2009-03-02 15:24 ` jakub at gcc dot gnu dot org
2009-03-03 11:30 ` jakub at gcc dot gnu dot org
2009-03-03 11:30 ` jakub 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).