Bug 82870 - [6 Regression] Assignment by Designated Initializer Overwrites a Flexible Array Member
Summary: [6 Regression] Assignment by Designated Initializer Overwrites a Flexible Arr...
Status: RESOLVED DUPLICATE of bug 81884
Alias: None
Product: gcc
Classification: Unclassified
Component: tree-optimization (show other bugs)
Version: 6.4.0
: P3 normal
Target Milestone: 6.5
Assignee: Not yet assigned to anyone
URL:
Keywords: wrong-code
Depends on:
Blocks:
 
Reported: 2017-11-06 23:38 UTC by Webstrand
Modified: 2017-11-07 12:36 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work: 7.2.1
Known to fail: 6.4.0, 7.2.0
Last reconfirmed: 2017-11-07 00:00:00


Attachments
Test-case which should succeed (312 bytes, text/plain)
2017-11-06 23:38 UTC, Webstrand
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Webstrand 2017-11-06 23:38:17 UTC
Created attachment 42553 [details]
Test-case which should succeed

GCC Version: 6.4.0
Target: x86_64-pc-linux-gnu
Configured with: /var/tmp/portage/sys-devel/gcc-6.4.0/work/gcc-6.4.0/configure --host=x86_64-pc-linux-gnu --build=x86_64-pc-linux-gnu --prefix=/usr --bindir=/usr/x86_64-pc-linux-gnu/gcc-bin/6.4.0 --includedir=/usr/lib/gcc/x86_64-pc-linux-gnu/6.4.0/include --datadir=/usr/share/gcc-data/x86_64-pc-linux-gnu/6.4.0 --mandir=/usr/share/gcc-data/x86_64-pc-linux-gnu/6.4.0/man --infodir=/usr/share/gcc-data/x86_64-pc-linux-gnu/6.4.0/info --with-gxx-include-dir=/usr/lib/gcc/x86_64-pc-linux-gnu/6.4.0/include/g++-v6 --with-python-dir=/share/gcc-data/x86_64-pc-linux-gnu/6.4.0/python --enable-languages=c,c++,fortran --enable-obsolete --enable-secureplt --disable-werror --with-system-zlib --enable-nls --without-included-gettext --enable-checking=release --with-bugurl=https://bugs.gentoo.org/ --with-pkgversion='Gentoo 6.4.0 p1.0' --disable-esp --enable-libstdcxx-time --enable-shared --enable-threads=posix --enable-__cxa_atexit --enable-clocale=gnu --enable-multilib --with-multilib-list=m32,m64 --disable-altivec --disable-fixed-point --enable-targets=all --disable-libgcj --enable-libgomp --disable-libmudflap --disable-libssp --disable-libcilkrts --disable-libmpx --enable-vtable-verify --enable-libvtv --enable-lto --without-isl --enable-libsanitizer --enable-default-pie --enable-default-ssp
Flags: -O3
Failing Command: gcc -O3 test.c && ./a.out

Compiling the attached source file and executing it results in an unexpected abort. Program should succeed silently.
Comment 1 Richard Biener 2017-11-07 09:18:51 UTC
    *obj = (struct Example){
        .bitmap = {0, 0, 0, 0, 0, 0}
    };

this _probably_ adds a single 0 for the flex array.  The bug seems to be fixed on the GCC 7 branch, confirmed on the tip of the GCC 6 branch.

GCC 6 DSEs the table[0] assignment in the following:

Example_assignment ()
{
  struct Example * obj;
  struct Example * D.1788;
  struct Example * obj;

  <bb 2>:
  obj_6 = __builtin_malloc (64);
  obj_6->table[0] = 1000;
  *obj_6 = {};
  return obj_6;


Wonder what fixed it / which bug is the dup.
Comment 2 Jakub Jelinek 2017-11-07 12:33:46 UTC
Started with r222305.  Went away with r251217.
Comment 3 Richard Biener 2017-11-07 12:36:06 UTC
Dup then.

*** This bug has been marked as a duplicate of bug 81884 ***