majintao0131 / yaml-cpp

Automatically exported from code.google.com/p/yaml-cpp
MIT License
0 stars 0 forks source link

Warning C4146 when using yaml-cpp in VS2010 #170

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Whenenver the >> operator is used to get data out of a YAML::Node, the 
following warnings show up (see attachment). It's really annoying as they end 
up flooding the compiler output, drowning any important warnings.

They only show up when compiling a program that uses yaml-cpp in Release mode 
(which includes Warning Level 3, /W3) in Visual Studio 2010.

Original issue reported on code.google.com by supsu...@gmail.com on 13 Sep 2012 at 4:00

Attachments:

GoogleCodeExporter commented 9 years ago
OK; but I don't have access to a Windows machine right now, so this may be a 
while, unless you want to supply a patch.

Original comment by jbe...@gmail.com on 13 Sep 2012 at 4:05

GoogleCodeExporter commented 9 years ago
Well I narrowed down the problem, but can't really figure out a good fix. 
VS2010 has a problem with line 61 in include/yaml-cpp/conversion.h of the old 
API (line 83 in include/yaml-cpp/node/convert.h in the new API):

} else if(IsNegativeInfinity(input)) {
>>  output = -std::numeric_limits<T>::infinity();
    return true;
}

Because when T is an unsigned type, there is no negative infinity, so the unary 
operator is pointless. But just adding a std::numeric_limits<T>::is_signed 
check isn't enough to shut it up, since it's a compile-time error, not run-time.

Original comment by supsu...@gmail.com on 14 Sep 2012 at 3:05

GoogleCodeExporter commented 9 years ago
I believe this was fixed in the new api with the "unary minus" bug.  This may 
be closeable/patchable in light of that fix.

Original comment by JohnMich...@gmail.com on 14 May 2013 at 2:00

GoogleCodeExporter commented 9 years ago

Original comment by jbe...@gmail.com on 24 Jan 2015 at 10:25