Bug 70749 - error: storage size of ‘a’ isn’t known goes away with -Os
Summary: error: storage size of ‘a’ isn’t known goes away with -Os
Status: RESOLVED DUPLICATE of bug 24293
Alias: None
Product: gcc
Classification: Unclassified
Component: c (show other bugs)
Version: 5.3.1
: P3 normal
Target Milestone: 6.0
Assignee: Not yet assigned to anyone
URL:
Keywords: accepts-invalid
Depends on:
Blocks:
 
Reported: 2016-04-21 09:57 UTC by ktkachov
Modified: 2021-09-17 05:24 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Known to work: 6.0, 7.0
Known to fail: 4.3.5, 4.9.4, 5.3.1
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description ktkachov 2016-04-21 09:57:49 UTC
I'm hitting an error when trying to build an allyesconfig arm64 linux kernel (4.5.2) (with an aarch64-none-linux-gnu toolchain).

drivers/staging/wilc1000/wilc_spi.c:123:34: error: storage size of ‘wilc1000_spi_ops’ isn’t known
 static const struct wilc1000_ops wilc1000_spi_ops;
                                  ^~~~~~~~~~~~~~~~

I don't get this error when compiling with the GCC 5 branch.
creduce reduces this to just:

static struct wilc1000_ops a;

The weird behaviour is on the GCC 5 branch in that I get the error:
bug.i:1:28: error: storage size of ‘a’ isn’t known
 static struct wilc1000_ops a;
                            ^
when compiling with -std=gnu89 bug.i -S
but it is compiled without an error (into an empty file) if I add -Os:
-std=gnu89 bug.i -S -Os

This behaviour occurs on GCC 5 and 4.9 and 4.8.
GCC 6 and trunk give the error regardless of optimization level.
Comment 1 Richard Biener 2016-04-21 10:09:40 UTC
What version works for you?  Even 4.3 doesn't error at -O.  I suspect older
compiler eliminate a before diagnosing it.
Comment 2 ktkachov 2016-04-21 10:12:55 UTC
Trunk errors with or without optimisation.
GCC 5 and earlier don't error with optimisation.

If this behaviour is expected (and the bug is in the kernel sources) feel free to close the report. I just thought it curious that the error depends on optimisation level.
Comment 3 Richard Biener 2016-05-06 07:42:57 UTC
*** Bug 70950 has been marked as a duplicate of this bug. ***
Comment 4 Andrew Pinski 2021-09-17 05:24:48 UTC
Dup of bug 24293.

*** This bug has been marked as a duplicate of bug 24293 ***