Infinite loop printing "warning: missing braces around initializer" in g++

Bug #944572 reported by nitrogen on 2012-03-02
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Linaro GCC
Fix Released
Michael Collison
Fix Released
gcc-4.6 (Ubuntu)

Bug Description

When compiling the attached malformed file with g++ -Wall, an infinite loop is entered that repeatedly prints the following message: warning: missing braces around initializer for ‘char [0]’ [-Wmissing-braces]

This affects all versions of gcc installed on the machine: 4.4, 4.5, and 4.6. The expected behavior is that the warning is printed once, then g++ exits (clang behaves as expected).

ProblemType: Bug
DistroRelease: Ubuntu 11.10
Package: g++-4.6 4.6.1-9ubuntu3
ProcVersionSignature: Ubuntu 3.0.0-16.28-generic 3.0.17
Uname: Linux 3.0.0-16-generic x86_64
NonfreeKernelModules: nvidia
ApportVersion: 1.23-0ubuntu4
Architecture: amd64
Date: Thu Mar 1 22:40:39 2012
ExecutablePath: /usr/bin/g++-4.6
InstallationMedia: Kubuntu 10.10 "Maverick Meerkat" - Release amd64 (20101007)
SourcePackage: gcc-4.6
UpgradeStatus: Upgraded to oneiric on 2011-11-09 (114 days ago)

nitrogen (i-am-nitrogen) wrote :
Matthias Klose (doko) wrote :

confirmed. the fsf releases don't print anything, but don't terminate either. I see the repeated error message for Linaro builds only

Changed in gcc-4.6 (Ubuntu):
importance: Undecided → Low
status: New → Confirmed
In , Doko-v (doko-v) wrote :

seen on 4.6, 4.7 and trunk on x86_64-linux-gnu

int main()
        char argv[][0] = {"", 0};

$ g++
doesn't terminate, or only if the VM get's exhausted.

Changed in gcc:
importance: Unknown → Medium
status: Unknown → New

I can confirm the problem for gcc 4.8 trunk for os=win32 arch=64bit systems

Zhenqiang Chen (zhenqiang-chen) wrote :

Thank you for the bug report. I've confirmed this with gcc-linaro-4.6-2012.08 and gcc-linaro-4.7-2012.08 on ARM:

./arm-linux-gnueabi-g++ -Wall warning: missing braces around initializer for ‘char [0]’ [-Wmissing-braces] warning: missing braces around initializer for ‘char [0]’ [-Wmissing-braces] warning: missing braces around initializer for ‘char [0]’ [-Wmissing-braces]

The compiler doesn't terminate.

Changed in gcc-linaro:
status: New → Confirmed
In , Paolo-k (paolo-k) wrote :

Author: paolo
Date: Thu Oct 18 22:48:35 2012
New Revision: 192592

2012-10-18 Paolo Carlini <email address hidden>

 PR c++/54501
 * decl.c (reshape_init_array_1): Avoid infinite loops.

2012-10-18 Paolo Carlini <email address hidden>

 PR c++/54501
 * g++.dg/init/array30.C: New.
 * g++.dg/init/array31.C: Likewise.


Fixed for 4.8.0.

Changed in gcc:
status: New → Fix Released
Michael Hope (michaelh1) wrote :

Worth backporting to 4.7?

Changed in gcc-linaro:
importance: Undecided → Low

Fixed in linaro gcc 4.8.

Changed in gcc-linaro:
assignee: nobody → Michael Collison (michael-collison)
status: Confirmed → Fix Released
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.