Bug 1672652
| Summary: | GCC error "initializer element is not constant" in gnu99 mode | ||
|---|---|---|---|
| Product: | Red Hat Enterprise Linux 7 | Reporter: | Thomas Huth <thuth> |
| Component: | gcc | Assignee: | Marek Polacek <mpolacek> |
| Status: | CLOSED ERRATA | QA Contact: | Alexandra Petlanová Hájková <ahajkova> |
| Severity: | medium | Docs Contact: | |
| Priority: | medium | ||
| Version: | 7.6 | CC: | ahajkova, fweimer, jakub, mcermak, ohudlick |
| Target Milestone: | rc | ||
| Target Release: | 7.7 | ||
| Hardware: | All | ||
| OS: | Linux | ||
| Whiteboard: | |||
| Fixed In Version: | gcc-4.8.5-38.el7 | Doc Type: | No Doc Update |
| Doc Text: | Story Points: | --- | |
| Clone Of: | Environment: | ||
| Last Closed: | 2019-08-06 13:00:39 UTC | Type: | Bug |
| Regression: | --- | Mount Type: | --- |
| Documentation: | --- | CRM: | |
| Verified Versions: | Category: | --- | |
| oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |
| Cloudforms Team: | --- | Target Upstream Version: | |
| Embargoed: | |||
We'd have to backport gcc.gnu.org/r216416 and gcc.gnu.org/r216440. I'm not sure if I want to backport those; how important is this? I think it is quite important. Since the GCC from RHEL7 is still using "gnu89" by default, while the GCCs of other newer distributions are using "gnu11" by default now, many upstream projects slowly switch away from "gnu89" and enforce either gnu99 or gnu11 for their project now. If the GCC from RHEL7 can not compile these projects in gnu99 (or gnu11) mode anymore, there is a chance that the projects stop support for RHEL7 completely. We've hit this problem when we switched the compile mode of the QEMU project to gnu99 recently: https://lists.gnu.org/archive/html/qemu-devel/2019-01/msg03279.html In that particular case, I was fortunately able to work-around the problem by manually changing the affected code, but I'm afraid that we will hit this problem sooner or later again, and not all cases can be solved easily (e.g. if the affected code is buried in the header of a library instead where you do not have direct control of). Reproduced on gcc-4.8.5-36.el7_6.1.x86_64. Corresponding tests passes on gcc-4.8.5-39.el7. Since the problem described in this bug report should be resolved in a recent advisory, it has been closed with a resolution of ERRATA. For information on the advisory, and where to find the updated files, follow the link below. If the solution does not work for you, open a new bug report. https://access.redhat.com/errata/RHBA-2019:2167 |
Description of problem: When compiling certain C code in gnu99 mode with the gcc v4.8.5 from RHEL7, I get the error "initializer element is not constant" and the compilation fails. The same code compiles fine in gnu89 mode or with later versions of GCC (e.g. version 8.x). Version-Release number of selected component (if applicable): gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-36) How reproducible: 100% Steps to Reproduce: 1. cat > gnu99bug.c <<EOF typedef struct { int value; } mytype_t; mytype_t myvar = (mytype_t) { .value = 0 }; EOF 2. gcc -Wall -std=gnu99 -c gnu99bug.c Actual results: gnu99bug.c:5:1: error: initializer element is not constant Expected results: gcc should compile this fine in gnu99 mode, just like later versions of gcc do it, and like it is also working fine in gnu89 mode. Additional info: I think this might be the upstream bug ticket: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63567