This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Allow compounds with empty initializer in pedantic mode (PR c/59351)


On 12/02/13 13:10, Marek Polacek wrote:
We triggered an assert on attached testcase, because when building the
compound literal with empty initial value complete_array_type returns
3, but we assert it returns 0.  It returns 3 only in the pedantic mode,
where empty initializer braces are forbidden.  Since we already gave
a warning, I think we could loosen the assert a bit and allow
empty initial values at that point.  sizeof on such compound literal
then yields zero, which I think is correct.
The assert exists even in GCC 4.0.

Regtested/botstrapped on x86_64-linux, ok for trunk and 4.8 and
perhaps even 4.7?

2013-12-02  Marek Polacek  <polacek@redhat.com>

	PR c/59351
c/
	* c-decl.c (build_compound_literal): Allow compound literals with
	empty initial value.
testsuite/
	* gcc.dg/pr59351.c: New test.
I was going to ask for some details about where we detect and warn to review that code as well, but given your test verifies the warning as well, we're good to go.

OK for the trunk.  Branch maintainers have final say for their branches.

Thanks,

Jeff


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]