Internal error in varasm.c

Bug #1848795 reported by Steve Wartik
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
gcc
Fix Released
Medium
gcc-7 (Ubuntu)
Won't Fix
Undecided
Unassigned

Bug Description

I am running g++ 7.4.0 on Ubuntu 18.04 (18.04.3 LTS). The full version line from g++ is:

    g++ (Ubuntu 7.4.0-1ubuntu1~18.04.1) 7.4.0

The error message is:

    /home/ilab-user/ida-fabric-core/test/integration-tests/it-02/expected-results.cpp:497:1: internal compiler error: in output_constructor_regular_field, at varasm.c:5030

The command line that generates the error is:

/usr/bin/c++ -DSTANDALONE -I/home/ilab-user/ida-fabric-core/test/integration-tests/it-02/../../../include -I/home/ilab-user/ida-fabric-core/test/integration-tests/it-02/../../../src/common -g -fPIE -Wall -g -std=gnu++11 -o CMakeFiles/it-02.dir/expected-results.cpp.o -c /home/ilab-user/ida-fabric-core/test/integration-tests/it-02/expected-results.cpp

I have attached the preprocessed output.

The output of apt-cache policy g++ is:

g++:
  Installed: 4:7.4.0-1ubuntu2.3
  Candidate: 4:7.4.0-1ubuntu2.3
  Version table:
 *** 4:7.4.0-1ubuntu2.3 500
        500 http://us.archive.ubuntu.com/ubuntu bionic-updates/main amd64 Packages
        500 http://security.ubuntu.com/ubuntu bionic-security/main amd64 Packages
        100 /var/lib/dpkg/status
     4:7.3.0-3ubuntu2 500
        500 http://us.archive.ubuntu.com/ubuntu bionic/main amd64 Packages

Revision history for this message
In , Rguenth (rguenth) wrote :

Created attachment 42024
unincluded unreduced testcase

> g++-7 -std=gnu++1z -S floc.cc
floc.cc:187:1: internal compiler error: in output_constructor_regular_field, at varasm.c:5030
    continue;
 ^
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://bugs.opensuse.org/> for instructions.

same ICE with gcc 6 and trunk.

Revision history for this message
In , Marxin-m (marxin-m) wrote :

Confirmed for following reduced test-case:

$ cat pr81922.ii
struct
{
  char *a;
  char b[];
} c[]{"", "", {}};

started with r234636. Is the original test-case really valid?

Revision history for this message
In , Jakub-gcc (jakub-gcc) wrote :

We have a bunch of other PRs for the lack of diagnostics of invalid initialization of flexible array members inside of arrays to non-empty array.
We just should diagnose it as invalid.

Revision history for this message
In , Jakub-gcc (jakub-gcc) wrote :

Created attachment 42811
gcc8-pr81922.patch

WIP patch that attempts to handle it like the C FE, will work on testcases tomorrow.

Revision history for this message
In , Jakub-gcc (jakub-gcc) wrote :

Author: jakub
Date: Fri Dec 15 20:20:00 2017
New Revision: 255703

URL: https://gcc.gnu.org/viewcvs?rev=255703&root=gcc&view=rev
Log:
 PR c++/80135
 PR c++/81922
 * typeck2.c (digest_init_r): Change nested argument type from bool to
 int. Use code instead of TREE_CODE (type) where possible. If
 nested == 2, diagnose initialization of flexible array member with
 STRING_CST. Pass nested to process_init_constructor. Formatting fix.
 (digest_init, digest_init_flags): Adjust digest_init_r caller.
 (massage_init_elt): Add nested argument. Pass 2 instead of 1 to
 digest_init_r's nested argument if nested is non-zero.
 (process_init_constructor_array): Add nested argument. If nested == 2,
 diagnose initialization of flexible array member with non-empty
 braced enclosed list. Pass nested to massage_init_elt.
 (process_init_constructor_record, process_init_constructor_union): Add
 nested argument, pass it to massage_init_elt.
 (process_init_constructor): Add nested argument, pass it to
 process_init_constructor_{array,record,union}.
 * init.c (find_field_init): Renamed to ...
 (find_flexarray_init): ... this. Return NULL_TREE if init is
 error_mark_node. Don't look through nested CONSTRUCTORs.
 (warn_placement_new_too_small): Adjust caller.

 * g++.dg/warn/Wplacement-new-size-1.C (fBx1): Initialize nested
 flexible array member only with {}. Add dg-warning.
 (fBx2, fBx3): Remove.
 * g++.dg/warn/Wplacement-new-size-2.C (fBx1): Initialize nested
 flexible array member only with {}. Add dg-warning.
 (fBx2, fBx3): Remove.
 * g++.dg/warn/Wplacement-new-size-6.C: New test.
 * g++.dg/ext/flexary13.C (main): Remove test for initialization
 of nested flexible array member with non-empty initializer.
 * g++.dg/ext/flexary25.C: New test.
 * g++.dg/ext/flexary26.C: New test.
 * g++.dg/ext/flexary27.C: New test.
 * g++.dg/parse/pr43765.C: Expect diagnostics about initialization
 of nested flexible array member with non-empty initializer. Expect
 C++2A diagnostics about mixing of designated and non-designated
 initializers.

Added:
    trunk/gcc/testsuite/g++.dg/ext/flexary25.C
    trunk/gcc/testsuite/g++.dg/ext/flexary26.C
    trunk/gcc/testsuite/g++.dg/ext/flexary27.C
    trunk/gcc/testsuite/g++.dg/warn/Wplacement-new-size-6.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/init.c
    trunk/gcc/cp/typeck2.c
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/g++.dg/ext/flexary13.C
    trunk/gcc/testsuite/g++.dg/parse/pr43765.C
    trunk/gcc/testsuite/g++.dg/warn/Wplacement-new-size-1.C
    trunk/gcc/testsuite/g++.dg/warn/Wplacement-new-size-2.C

Revision history for this message
In , Jakub-gcc (jakub-gcc) wrote :

Fixed on the trunk. Unsure about backports.

Revision history for this message
In , Jakub-gcc (jakub-gcc) wrote :

GCC 6 branch is being closed

Revision history for this message
Steve Wartik (swartik) wrote :
Revision history for this message
Matthias Klose (doko) wrote :

first error with g++-8 and g++-9:

expected-results.cpp:67:29: error: initialization of flexible array member in a nested context

Changed in gcc-7 (Ubuntu):
status: New → Confirmed
Revision history for this message
Matthias Klose (doko) wrote :

$ cat expected-results.ii
# 1 "" 3
namespace a {
namespace b {
enum c { d };
}
} // namespace a
struct {
  a::b::c e;
  char f[];
} g[]{a::b::d, "nodeid", {}};

$ g++-7 -Wall -std=gnu++11 -c expected-results.ii
:9:29: internal compiler error: in output_constructor_regular_field, at varasm.c:5035
Please submit a full bug report,
with preprocessed source if appropriate.

$ g++-8 -Wall -std=gnu++11 -c expected-results.ii
:9:28: error: initialization of flexible array member in a nested context

Revision history for this message
Matthias Klose (doko) wrote :

fixed in 8 and 9, won't fix in 7.

Changed in gcc-7 (Ubuntu):
status: Confirmed → Won't Fix
Changed in gcc:
importance: Unknown → Medium
status: Unknown → Confirmed
Revision history for this message
In , Rguenth (rguenth) wrote :

Fixed in GCC 8.

Changed in gcc:
status: Confirmed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

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