[llvm-commits] Patch for undefined behaviour in ManagedStatic.h

Owen Anderson resistor at mac.com
Thu Jul 9 09:42:01 PDT 2009


On Jul 9, 2009, at 2:10 AM, AlisdairM(public) wrote:

> The attached patch resolves undefined behaviour in ManagedStatic.h  
> when the ManagedStatic template is instantiated with an array type.
>
> I would really like some feedback before committing as I have only  
> been able to test it on Microsoft compilers - I can't get a MinGW  
> config to work for me yet.  It would be best to confirm other  
> compilers' handling of this situation before changing the current  
> behaviour.
>
> As far as Microsoft is concerned, they detect the undefined  
> behaviour, issue a warning and call the right delete operator behind  
> the scenes.  So for MSVC, this is simply eliminating a warning.  If  
> other compilers handle the object_creator call badly though, this  
> 'fix' might actually break code (assuming buggy compilers).  On the  
> other hand, it might be genuinely fixing a bug in llvm if a compiler  
> strictly follows the C++ rules.  This is one of those potentially  
> grey areas I don't necessarily trust compilers to get it right.
>
> For reference, the issue arises with the declaration of
>  ManagedStatic<PsuedoSourceValue[4]> PSVs
> in CodeGen/PseudoSourceValue.cpp
>
> This is the only instantiation with an array that I know of.

Nice catch, Alisdair.  I've confirmed that you patch works correctly  
on Darwin.

--Owen



More information about the llvm-commits mailing list