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

Douglas Gregor dgregor at apple.com
Mon Aug 23 22:28:39 PDT 2010


On Aug 23, 2010, at 9:06 PM, Faisal Vali wrote:

> 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! Committed as r111900 with a few minor tweaks.

	- Doug




More information about the cfe-commits mailing list