This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/34586] New: consts cannot be used to initialize static declarations as per be below code snippet
- From: "dragonheart at gentoo dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 25 Dec 2007 09:06:51 -0000
- Subject: [Bug c/34586] New: consts cannot be used to initialize static declarations as per be below code snippet
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
consts cannot be used to initialize static declarations as per below code
snippet (thanks to Christophe Grenier).
int main()
{
const unsigned int sizeof_buffer=512;
static long long bmplcn = -sizeof_buffer - 1;
printf("bmplcn=%lld\n", bmplcn);
return 0;
}
gcc -o /tmp/main /tmp/main.c
/tmp/main.c: In function 'main':
/tmp/main.c:5: error: initializer element is not constant
Confirmed with other gentoo devs that this fails in 4.2.2 as well.
gcc --version
gcc (GCC) 4.2.0 (Gentoo 4.2.0 p1.4)
--
Summary: consts cannot be used to initialize static declarations
as per be below code snippet
Product: gcc
Version: 4.2.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: dragonheart at gentoo dot org
GCC build triplet: x86_64-pc-linux-gnu
GCC host triplet: x86_64-pc-linux-gnu
GCC target triplet: x86_64-pc-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34586