Bug 37481 - -pedantic accepts flexible array member = "string" initialization
Summary: -pedantic accepts flexible array member = "string" initialization
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c (show other bugs)
Version: 4.3.2
: P3 minor
Target Milestone: 4.5.0
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks: 16989
  Show dependency treegraph
 
Reported: 2008-09-11 16:29 UTC by Hallvard B Furuseth
Modified: 2009-04-19 20:40 UTC (History)
1 user (show)

See Also:
Host: i686-pc-linux-gnu
Target: i686-pc-linux-gnu
Build: i686-pc-linux-gnu
Known to work: 4.5.0
Known to fail:
Last reconfirmed: 2008-09-11 16:58:02


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Hallvard B Furuseth 2008-09-11 16:29:28 UTC
struct Foo { int i; char a[]; } foo = { 1, "" };   // No warning
struct Bar { int i; char a[]; } bar = { 1, {0} };  // Warning

Line 1 passes -pedantic, but C99 6.7.2.1p16 says it is invalid:
Flexible array members are ignored except with ',', '->',
and for aligning the size of the struct.

Related: Bug 20407: g++ does reject it, even without -pedantic.
Comment 1 Joseph S. Myers 2009-04-19 20:39:15 UTC
Subject: Bug 37481

Author: jsm28
Date: Sun Apr 19 20:38:53 2009
New Revision: 146359

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=146359
Log:
	PR c/37481
	* c-typeck.c (digest_init): Check for initializing an array with a
	string literal.

testsuite:
	* gcc.dg/c99-flex-array-7.c: New test.

Added:
    trunk/gcc/testsuite/gcc.dg/c99-flex-array-7.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/c-typeck.c
    trunk/gcc/testsuite/ChangeLog

Comment 2 Joseph S. Myers 2009-04-19 20:40:11 UTC
Fixed for 4.5.