public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/102238] New: alias_offset in gimple-ssa-sprintf.c is broken
@ 2021-09-08  3:11 pinskia at gcc dot gnu.org
  2021-09-08  3:13 ` [Bug tree-optimization/102238] " pinskia at gcc dot gnu.org
                   ` (10 more replies)
  0 siblings, 11 replies; 12+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-09-08  3:11 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102238

            Bug ID: 102238
           Summary: alias_offset in gimple-ssa-sprintf.c is broken
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Keywords: diagnostic
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: pinskia at gcc dot gnu.org
  Target Milestone: ---

Take:
/* 
   { dg-do compile }
   { dg-options "-O2 -Wno-format-overflow -Wrestrict -ftrack-macro-expansion=0"
}
*/
void sink (int);
#define S10 "0123456789"
extern char a2[2][22];
#define T(d, ...) do {                                  \
    char a[22] = S10;                                   \
    sink (__builtin_sprintf ((d), __VA_ARGS__));        \
  } while (0)
struct S {
  char a[4];
  char b[4];
};
struct S2 {
  struct S s_1;
  struct S s_2;
  struct S sa3[3];
};
struct S3 {
  struct S2 s2_1;
  struct S2 s2_2;

  struct {
    struct {
      struct {
        struct S sa_3[3];
      } a_1[3];
    } a_2[3][3];
  } a_3[3][3][3];

  char fa[];
};
void test_struct_member_array (struct S3 *s3, int i)
{
  char *a = (char*)s3;
  char *d;
  const char *s;
  d = s3->s2_2.s_1.a;
  s = s3->s2_2.s_1.a;
  T (d, "%s", a + 40);   /* { dg-warning "overlaps" } */
  T (d, "%s", a + 41);   /* { dg-warning "may overlap" } */
  T (d, "%s", a + 42);   /* { dg-warning "may overlap" } */
}

----- CUT -----

This should warn but does not.
The reason is alias_offset does not do a good job at all figuring out field
offsets.

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

end of thread, other threads:[~2021-11-23 10:16 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-08  3:11 [Bug tree-optimization/102238] New: alias_offset in gimple-ssa-sprintf.c is broken pinskia at gcc dot gnu.org
2021-09-08  3:13 ` [Bug tree-optimization/102238] " pinskia at gcc dot gnu.org
2021-09-15 16:40 ` msebor at gcc dot gnu.org
2021-09-15 19:19 ` pinskia at gcc dot gnu.org
2021-09-15 19:21 ` pinskia at gcc dot gnu.org
2021-09-16 17:28 ` msebor at gcc dot gnu.org
2021-09-16 17:29 ` msebor at gcc dot gnu.org
2021-09-16 17:40 ` pinskia at gcc dot gnu.org
2021-09-16 22:56 ` msebor at gcc dot gnu.org
2021-10-24 23:45 ` [Bug tree-optimization/102238] missing -Wrestrict for sprintf into the same member array as argument plus offset msebor at gcc dot gnu.org
2021-10-26 22:54 ` cvs-commit at gcc dot gnu.org
2021-11-23 10:16 ` pinskia at gcc dot gnu.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).