[cfe-dev] [PATCH] for bug 6904 - clang allows redefinition of static const member

Faisal Vali faisalv at yahoo.com
Mon Aug 23 21:03:59 PDT 2010


Doug,
   As per your instructions to me in the cfe-dev group, I am posting
this patch to the cfe-commits group.

All,

This patch is supposed to address the following bug:
http://llvm.org/bugs/show_bug.cgi?id=6904#c2
Essentially clang allows the following redefinition, and it shouldn't :
struct S { static const int i = 0; }; const int S::i = 5;

The patch is quite simple and basically checks each variable
declaration if it has previously been initialized (this is a separate
check from a definition check only in the case of the in-class static
int initializer i believe), before it adds an initializer.
Because there are two separate functions that do DirectInitialization
and CopyInitialization, I added the exact same code to both of them.

I would appreciate any feedback.
Thanks!
Faisal Vali
-------------- next part --------------
A non-text attachment was scrubbed...
Name: int-static-var-redef-bug-2.patch
Type: application/octet-stream
Size: 5085 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20100823/0585d5e2/attachment.obj>


More information about the cfe-dev mailing list