[LLVMdev] Visual Studio 2010 build warning & errors

Michael Spencer bigcheesegs at gmail.com
Thu Sep 23 04:04:41 PDT 2010


On Thu, Sep 23, 2010 at 2:40 AM, Nathan Jeffords
<blunted2night at gmail.com> wrote:
> here are a couple of patches to address some warnings
> in Microsoft compilers, and a build error in vs2010 in particular
> vs2010-errors.patch:
> In SelectionDAGISel,  std::pairs or pointers are being constructed using a 0
> as an initializer causes an error inside the std::pair constructor. I think
> changes to language in support of the nullptr keyword caused this break.

Yep, people keep doing this. I've been behind on the trunk for a bit,
but I was surprised to see this come up again. This is the correct
fix, but please make sure you stick within 80 cols.

> vs2010-warnings.patch:
> This patch fixes a couple of annoying warnings that show up all over the
> place because they are in headers. At least for Microsoft compilers,
> conversion of a int to bool requires the compiler to convert non-zero to one
> and so the compiler warns of the performance issue. My fix is to explicitly
> perform the conversion so the compiler knows I'm aware and doesn't warn me.
> I don't know the behavior of other compilers in this respect, so I don't
> know if it should be committed. The other solution would be to change the
> return type of the accessors function to return ints, though this could move
> the warning elsewhere.
> -Nathan

This fix looks like a case of 3am programming. I think using
static_cast<bool> is clearer.

- Michael Spencer




More information about the llvm-dev mailing list