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

AlisdairM(public) public at alisdairm.net
Thu Jul 9 02:10:05 PDT 2009


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.

AlisdairM

-------------- next part --------------
A non-text attachment was scrubbed...
Name: ManagedStatic.patch
Type: application/octet-stream
Size: 1894 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20090709/d0e66cac/attachment.obj>


More information about the llvm-commits mailing list