internal compiler error with std::array designated initialization

Bug #1313102 reported by Tim Cooijmans on 2014-04-26
10
This bug affects 1 person
Affects Status Importance Assigned to Milestone
gcc
New
Medium
gcc-4.8 (Ubuntu)
Low
Unassigned
Trusty
Undecided
Unassigned
gcc-4.9 (Ubuntu)
Low
Unassigned
Trusty
Undecided
Unassigned
gccgo-4.9 (Ubuntu)
Undecided
Unassigned
Trusty
Undecided
Unassigned

Bug Description

The following code fails to compile with g++-4.8:

  #include <array>
  const int i = 0;
  std::array<int, 1> bar = {
    [i] = 0
  };

I have since learned that designated initialization is not supported in (GNU) C++. In that case I would have expected a syntax error.

This is the compilation command and its output:

  $ g++-4.8 -Wall -std=gnu++11 main.cpp
  main.cpp:5:1: internal compiler error: in lookup_field_1, at cp/search.c:384
   };
   ^
  Please submit a full bug report,
  with preprocessed source if appropriate.
  See <file:///usr/share/doc/gcc-4.8/README.Bugs> for instructions.
  Preprocessed source stored into /tmp/ccUsV9BC.out file, please attach this to your bugreport.

The preprocessed source file is attached. g++-4.8 --version reports g++-4.8 (Ubuntu 4.8.1-2ubuntu1~12.04) 4.8.1. I installed this package using the instructions given in this answer: http://askubuntu.com/a/271561. Ubuntu release and package version are:

$ lsb_release -rd
Description: Ubuntu 12.04.4 LTS
Release: 12.04
$ apt-cache policy g++-4.8
g++-4.8:
  Installed: 4.8.1-2ubuntu1~12.04
  Candidate: 4.8.1-2ubuntu1~12.04
  Version table:
 *** 4.8.1-2ubuntu1~12.04 0
        500 http://ppa.launchpad.net/ubuntu-toolchain-r/test/ubuntu/ precise/main i386 Packages
        100 /var/lib/dpkg/status

Tim Cooijmans (tim-cooijmans) wrote :
In , Doko-v (doko-v) wrote :

4.7 rejects this without an ICE, the ICE is seen on 4.8, 4.9 branches and trunk.

$ cat tst.cc
#include <array>
  const int i = 0;
  std::array<int, 1> bar = {
    [i] = 0
  };

$ g++-4.7 -Wall -std=gnu++0x tst.cc
tst.cc:5:3: error: 'std::array<int, 1ul>' has no non-static data member named 'i'

$ g++-4.8 -Wall -std=gnu++0x tst.cc
tst.cc:5:3: internal compiler error: in lookup_field_1, at cp/search.c:384
   };
   ^
Please submit a full bug report,
with preprocessed source if appropriate.

Matthias Klose (doko) on 2014-05-03
Changed in gcc-4.8 (Ubuntu):
importance: Undecided → Medium
status: New → Triaged
importance: Medium → Low
Changed in gcc-4.9 (Ubuntu):
importance: Undecided → Low
status: New → Triaged
Changed in gcc:
importance: Unknown → Medium
status: Unknown → New
Matthias Klose (doko) on 2014-06-03
Changed in gcc-4.9 (Ubuntu Trusty):
status: New → Invalid
Changed in gccgo-4.9 (Ubuntu):
status: New → Invalid
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package gcc-4.8 - 4.8.3-3ubuntu1

---------------
gcc-4.8 (4.8.3-3ubuntu1) utopic; urgency=medium

  * Merge with Debian; remaining changes:
    - Build from the upstream source.

gcc-4.8 (4.8.3-3) unstable; urgency=medium

  * Update to SVN 20140606 (r211339) from the gcc-4_8-branch.
  * Don't install the libstdc++ pretty printer file into the debug directory,
    but into the gdb auto-load directory.
  * Fix the removal of the libstdc++6 package, removing byte-compiled pretty
    printer files and pycache directories.
  * Fix PR c++/61046, taken from the trunk. LP: #1313102.
 -- Matthias Klose <email address hidden> Sat, 07 Jun 2014 10:10:24 +0200

Changed in gcc-4.8 (Ubuntu):
status: Triaged → Fix Released
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package gcc-4.9 - 4.9.0-6ubuntu1

---------------
gcc-4.9 (4.9.0-6ubuntu1) utopic; urgency=medium

  * Update to SVN 20140610 (r211403) from the gcc-4_9-branch.

gcc-4.9 (4.9.0-6) unstable; urgency=medium

  * Update to SVN 20140608 (r211353) from the gcc-4_9-branch.
  * Fix -Wno-format when -Wformat-security is the default (Steve Beattie).
    LP: #1317305.
  * Don't install the libstdc++ pretty printer file into the debug directory,
    but into the gdb auto-load directory.
  * Fix the removal of the libstdc++6 package, removing byte-compiled pretty
    printer files and pycache directories.
  * Fix PR c++/61046, taken from the trunk. LP: #1313102.
  * Fix installation of gcc-{ar,nm,ranlib} man pages for snapshot builds.
    Closes: #745906.
  * Update patches for snapshot builds.
 -- Matthias Klose <email address hidden> Tue, 10 Jun 2014 12:29:10 +0200

Changed in gcc-4.9 (Ubuntu):
status: Triaged → Fix Released
Steve Langasek (vorlon) wrote :

this is a C++-specific change; no verification is required for gccgo-4.9 in trusty.

Changed in gccgo-4.9 (Ubuntu Trusty):
status: New → Invalid
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package gccgo-4.9 - 4.9.1-0ubuntu1

---------------
gccgo-4.9 (4.9.1-0ubuntu1) trusty-proposed; urgency=medium

  * Upload the final GCC 4.9.1 release.
  * Merge changes from gcc-4.9 4.9.0-2ubuntu1, including:
    - Fix PR go/60931, garbage collector issue with non 4kB system page size.
      LP: #1304754.
    - Fix wrong-code issue in the little endian vector API (ppc64el).
      LP: #1311128.
    - Fix ABI incompatibility between POWER and Z HTM builtins and intrinsics.
      LP: #1320292.
    - Fix an ICE with invalid code. PR c++/61046. LP: #1313102.
    - gccgo: Don't overwrite memory if an archive has a bad file name.
  * Include the cc1 binary into the gccgo-4.9 package.
  * Do not build-depend on sdt-systemtap for the trusty upload.
  * Warn about ppc ELFv2 ABI issues, which will change in GCC 4.10.
 -- Matthias Klose <email address hidden> Thu, 17 Jul 2014 15:51:15 +0200

Changed in gccgo-4.9 (Ubuntu Trusty):
status: Invalid → Fix Released

The verification of the Stable Release Update for gccgo-4.9 has completed successfully and the package has now been released to -updates. Subsequently, the Ubuntu Stable Release Updates Team is being unsubscribed and will not receive messages about this bug report. In the event that you encounter a regression using the package from -updates please report a new bug using ubuntu-bug and tag the bug report regression-update so we can easily find any regressions.

Hello Tim, or anyone else affected,

Accepted gcc-4.8 into trusty-proposed. The package will build now and be available at https://launchpad.net/ubuntu/+source/gcc-4.8/4.8.4-2ubuntu1~14.04 in a few hours, and then in the -proposed repository.

Please help us by testing this new package. See https://wiki.ubuntu.com/Testing/EnableProposed for documentation how to enable and use -proposed. Your feedback will aid us getting this update out to other Ubuntu users.

If this package fixes the bug for you, please add a comment to this bug, mentioning the version of the package you tested, and change the tag from verification-needed to verification-done. If it does not fix the bug for you, please add a comment stating that, and change the tag to verification-failed. In either case, details of your testing will help us make a better decision.

Further information regarding the verification process can be found at https://wiki.ubuntu.com/QATeam/PerformingSRUVerification . Thank you in advance!

Changed in gcc-4.8 (Ubuntu Trusty):
status: New → Fix Committed
tags: added: verification-needed
Matthias Klose (doko) wrote :

$ g++ -m32 -std=gnu++11 main.cpp
main.cpp:5:1: error: '[i] =' used in a GNU-style designated initializer for class 'std::array<int, 1u>'
 # 1 "/usr/include/c++/4.8/array" 1 3
 ^

fixed

tags: added: verification-done
removed: verification-needed
Launchpad Janitor (janitor) wrote :
Download full text (19.4 KiB)

This bug was fixed in the package gcc-4.8 - 4.8.4-2ubuntu1~14.04

---------------
gcc-4.8 (4.8.4-2ubuntu1~14.04) trusty-proposed; urgency=medium

  * SRU LP: #1311866.
  * Fix PR tree-optimization/63341 (wrong code, rs6000).
  * Allow to turn off -Wformat using Wno-format. LP: #1401836.
  * Fix PR target/60693 (x86, ice on valid code). LP: #1378737.
  * Fix PR tree-optimization/61964 (wrong code). LP: #1347147.
  * Fix GCC miscompilation with boost::asio::io_service::work. LP: #1338693.
  * Fix PR target/61208 (POWER, wrong code). LP: #1322287.
  * Fix ABI incompatibility between POWER and Z HTM builtins and intrinsics.
    LP: #1320292.
  * Fix PR c++/61046 (ice on invalid code). LP: #1313102.
  * Fix wrong-code issue in the little endian vector API (ppc64el).
    LP: #1311128.
  * Fix PR tree-optimization/59358 (wrong code). LP: #1395019.
  * Fix ice on ARM32. LP: #1268893.
  * Don't apply the backport for PR61841 for trusty, causing link failures.
  * Fix wrong code for vector doubleword extract (POWER). LP: #1437467.

gcc-4.8 (4.8.4-2ubuntu1) vivid; urgency=medium

  * Merge with Debian; remaining changes:
    - Build from the upstream source.

gcc-4.8 (4.8.4-2) unstable; urgency=medium

  * Update to SVN 20150426 (r222448) from the gcc-4_8-branch.
    - Fix PR libstdc++/60966, PR c/61553, PR middle-end/63704,
      PR target/61413 (ARM), PR target/64358 (RS6000), PR target/64479 (SH),
      PR target/64409 (x86), PR rtl-optimization/64037, PR c++/64487,
      PR c++/64251, PR c++/64297, PR fortran/63733, PR fortran/64244,
      PR c/64766, PR target/64882, PR rtl-optimization/61058,
      PR middle-end/43631, PR tree-optimization/64563, PR target/64513,
      PR middle-end/57748, PR middle-end/57748, PR target/64795,
      PR fortran/64528, PR fortran/56867, PR fortran/57023, PR c/57653,
      PR tree-optimization/63844 (OpenMP), PR middle-end/64199 (ice on valid),
      PR tree-optimization/64493 (ice on valid), PR tree-optimization/64495
      (wrong code), PR tree-optimization/56273 (diagnostics),
      PR tree-optimization/59124 (diagnostic), PR tree-optimization/64277
      (diagnostic), PR lto/65015, PR target/65163 (SH), PR target/64113 (ALPHA,
      link failure), PR rtl-optimization/64557, PR rtl-optimization/63475
      (ALPHA, wrong code), PR rtl-optimization/63483 (ALPHA, wrong code),
      PR target/64452 (AVR), PR target/64387 (x86, ice on valid),
      PR target/64979 (wrong code), PR target/64580 (rs6000),
      PR fortran/63744 (rejects valid), PR lto/65193 (ice on valid),
      PR tree-optimization/61634 (ice on valid), PR target/65196 (AVR),
      PR tree-optimization/63593 (ice on valid),
      PR tree-optimization/65063 (wrong code), PR target/65286 (rs6000),
      PR 65138/target (rs6000), PR target/53988 (SH), PR target/59593 (ARM),
      PR target/64453 (ARM), PR middle-end/65409 (ice on valid),
      PR tree-optimization/65388, PR fortran/65024 (ice),
      PR fortran/60898 (ice on valid), PR fortran/61138, PR libgfortran/60956,
      PR libstdc++/65279, PR libstdc++/65543, PR target/65849, PR target/65456,
      PR target/65787, PR c++/65727, PR c++/65721, PR fortran/56674,
      PR fortran/58813, PR fortran/590...

Changed in gcc-4.8 (Ubuntu Trusty):
status: Fix Committed → Fix Released
Steve Langasek (vorlon) wrote :

Hello Tim, or anyone else affected,

Accepted gccgo-4.9 into trusty-proposed. The package will build now and be available at https://launchpad.net/ubuntu/+source/gccgo-4.9/4.9.3-0ubuntu4 in a few hours, and then in the -proposed repository.

Please help us by testing this new package. See https://wiki.ubuntu.com/Testing/EnableProposed for documentation how to enable and use -proposed. Your feedback will aid us getting this update out to other Ubuntu users.

If this package fixes the bug for you, please add a comment to this bug, mentioning the version of the package you tested, and change the tag from verification-needed to verification-done. If it does not fix the bug for you, please add a comment stating that, and change the tag to verification-failed. In either case, details of your testing will help us make a better decision.

Further information regarding the verification process can be found at https://wiki.ubuntu.com/QATeam/PerformingSRUVerification . Thank you in advance!

tags: removed: verification-done
tags: added: verification-needed
Steve Langasek (vorlon) wrote :

This is a C++-specific bug which is not applicable to the gccgo-4.9 SRU in progress.

tags: added: verification-done
removed: verification-needed
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.