Is this a compiler error in updating MSVC ++ 2017 3

#include <vector>

std::vector<int>::iterator foo();
void bar(void*) {}

int main()
{
    void* p;
    while (foo() != foo() && (p = 0, true))
    {
        bar(p);
    }
    return 0;
}

Error results:

c: \ users \ jessepepper \ source \ repos \ testcode \ consoleapplication1 \ consoleapplication1.cpp (15): error C4703: potentially uninitialized local pointer variable 'p' is used

+4
source share
2 answers

This is a kind of error, but very typical of the type of code you write.

-, , . C4703 4 ( , ). , (, , ), , (/W4 /Werror, , ).

. , , ? ? , ( - ). , , , , .

, : p ( , foo() != foo()). p ( , - ). ( , , foo() != foo() , ). , , .

, . , , , , . , , ?

+5

V++ 2017 Preview.

. , , albetit smelly.

. (. @SebastianRedl.) V++ 2017 , , , " " . - , "" - , " ". , , " " , , , . , IMO.

, . , , . , , .

, Visual Studio .

+2

Source: https://habr.com/ru/post/1694637/


All Articles