newmind / googletest

Automatically exported from code.google.com/p/googletest
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

Assert failure on Gtest 1.5 with VS2005+sp1 #307

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1.Compile Gtest1.5 and then run gtest_unittest.exe

What is the expected output? What do you see instead?
In this test case "TEST(HRESULTAssertionTest, EXPECT_HRESULT_SUCCEEDED) 
", Assert failure appeared in isctype.c _chvalidator(-49,8), para -49 cause 
_ASSERTE((unsigned)(c + 1) <= 256) to produce a assert failue. 

What version of Google Test are you using? On what operating system?
winXP + VS2005SP1, Gtest1.5

Please provide any additional information below, such as a code snippet.

below is the call stack:
>   gtest_unittest.exe!_chvalidator(int c=-49, int mask=8)  Line 56 C++
    gtest_unittest.exe!isspace(int c=-49)  Line 189 + 0xb bytes C++
    gtest_unittest.exe!testing::internal::`anonymous namespace'::HRESULTFailureHelper(const char * expr=0x0061bb64, const char * expected=0x006250b8, long hr=-2147418113)  Line 1384 + 0x2c bytes  C++
    gtest_unittest.exe!testing::internal::IsHRESULTSuccess(const char * expr=0x0061bb64, long hr=-2147418113)  Line 1403 + 0x16 bytes   C++
    gtest_unittest.exe!`anonymous namespace'::HRESULTAssertionTest_EXPECT_HRESULT_SUCCEEDED_Test::TestBody()  Line 3826 + 0x57 bytes    C++
    gtest_unittest.exe!testing::Test::Run()  Line 2070 + 0xf bytes  C++
    gtest_unittest.exe!testing::internal::TestInfoImpl::Run()  Line 2318    C++
    gtest_unittest.exe!testing::TestCase::Run()  Line 2421  C++
    gtest_unittest.exe!testing::internal::UnitTestImpl::RunAllTests()  Line 4025    C++
    gtest_unittest.exe!testing::UnitTest::Run()  Line 3677 + 0xb bytes  C++
    gtest_unittest.exe!main(int argc=1, char * * argv=0x00033940)  Line 39  C++
    gtest_unittest.exe!__tmainCRTStartup()  Line 327 + 0x19 bytes   C
    gtest_unittest.exe!mainCRTStartup()  Line 196   C
    kernel32.dll!7c816fe7()     

Original issue reported on code.google.com by zhang....@huawei.com on 28 Aug 2010 at 3:43

GoogleCodeExporter commented 9 years ago
IsHRESULTSuccess() calls isspace(), which accepts either an unsigned char or 
EOF.  We are giving it a char, which could be signed depending on the compiler 
flags.  We should cast the char to unsigned char before calling isspace().

Original comment by zhanyong...@gmail.com on 30 Aug 2010 at 5:52

GoogleCodeExporter commented 9 years ago
This should be fixed in trunk r480.

Original comment by zhanyong...@gmail.com on 31 Aug 2010 at 6:22