Is this a compiler bug in MSVC++ 2017 update 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;
}
Results in error:
c:usersjessepeppersourcerepostestcodeconsoleapplication1consoleapplication1.cpp(15): error C4703: potentially uninitialized local pointer variable 'p' used
c++ visual-studio compiler-bug
|
show 8 more comments
#include <vector>
std::vector<int>::iterator foo();
void bar(void*) {}
int main()
{
void* p;
while (foo() != foo() && (p = 0, true))
{
bar(p);
}
return 0;
}
Results in error:
c:usersjessepeppersourcerepostestcodeconsoleapplication1consoleapplication1.cpp(15): error C4703: potentially uninitialized local pointer variable 'p' used
c++ visual-studio compiler-bug
5
Upvoted, but can you give a slightly less convoluted and more motivating example?
– StoryTeller
Mar 8 '18 at 8:13
1
What would you expect?
– Serge Ballesta
Mar 8 '18 at 8:26
1
I don't see how the value ofp
could be accessed before it is initialized. Moreover on the version of MSVC on compiler explorer, the code just compile without error link. Certainly a compiler bug.
– Oliv
Mar 8 '18 at 8:34
1
@M.M it should certainly compile though, yet it doesn't.
– Quentin
Mar 8 '18 at 9:05
1
Did not understand why you need thiswhile (foo() != foo() && (p = 0, true))
, especially(p = 0, true)
part? To test a "trick" and make program less readable? Why not!(p = 0)
instead of(p = 0, true)
?
– i486
Mar 8 '18 at 9:13
|
show 8 more comments
#include <vector>
std::vector<int>::iterator foo();
void bar(void*) {}
int main()
{
void* p;
while (foo() != foo() && (p = 0, true))
{
bar(p);
}
return 0;
}
Results in error:
c:usersjessepeppersourcerepostestcodeconsoleapplication1consoleapplication1.cpp(15): error C4703: potentially uninitialized local pointer variable 'p' used
c++ visual-studio compiler-bug
#include <vector>
std::vector<int>::iterator foo();
void bar(void*) {}
int main()
{
void* p;
while (foo() != foo() && (p = 0, true))
{
bar(p);
}
return 0;
}
Results in error:
c:usersjessepeppersourcerepostestcodeconsoleapplication1consoleapplication1.cpp(15): error C4703: potentially uninitialized local pointer variable 'p' used
c++ visual-studio compiler-bug
c++ visual-studio compiler-bug
asked Mar 8 '18 at 8:11
Jesse PepperJesse Pepper
2,4992342
2,4992342
5
Upvoted, but can you give a slightly less convoluted and more motivating example?
– StoryTeller
Mar 8 '18 at 8:13
1
What would you expect?
– Serge Ballesta
Mar 8 '18 at 8:26
1
I don't see how the value ofp
could be accessed before it is initialized. Moreover on the version of MSVC on compiler explorer, the code just compile without error link. Certainly a compiler bug.
– Oliv
Mar 8 '18 at 8:34
1
@M.M it should certainly compile though, yet it doesn't.
– Quentin
Mar 8 '18 at 9:05
1
Did not understand why you need thiswhile (foo() != foo() && (p = 0, true))
, especially(p = 0, true)
part? To test a "trick" and make program less readable? Why not!(p = 0)
instead of(p = 0, true)
?
– i486
Mar 8 '18 at 9:13
|
show 8 more comments
5
Upvoted, but can you give a slightly less convoluted and more motivating example?
– StoryTeller
Mar 8 '18 at 8:13
1
What would you expect?
– Serge Ballesta
Mar 8 '18 at 8:26
1
I don't see how the value ofp
could be accessed before it is initialized. Moreover on the version of MSVC on compiler explorer, the code just compile without error link. Certainly a compiler bug.
– Oliv
Mar 8 '18 at 8:34
1
@M.M it should certainly compile though, yet it doesn't.
– Quentin
Mar 8 '18 at 9:05
1
Did not understand why you need thiswhile (foo() != foo() && (p = 0, true))
, especially(p = 0, true)
part? To test a "trick" and make program less readable? Why not!(p = 0)
instead of(p = 0, true)
?
– i486
Mar 8 '18 at 9:13
5
5
Upvoted, but can you give a slightly less convoluted and more motivating example?
– StoryTeller
Mar 8 '18 at 8:13
Upvoted, but can you give a slightly less convoluted and more motivating example?
– StoryTeller
Mar 8 '18 at 8:13
1
1
What would you expect?
– Serge Ballesta
Mar 8 '18 at 8:26
What would you expect?
– Serge Ballesta
Mar 8 '18 at 8:26
1
1
I don't see how the value of
p
could be accessed before it is initialized. Moreover on the version of MSVC on compiler explorer, the code just compile without error link. Certainly a compiler bug.– Oliv
Mar 8 '18 at 8:34
I don't see how the value of
p
could be accessed before it is initialized. Moreover on the version of MSVC on compiler explorer, the code just compile without error link. Certainly a compiler bug.– Oliv
Mar 8 '18 at 8:34
1
1
@M.M it should certainly compile though, yet it doesn't.
– Quentin
Mar 8 '18 at 9:05
@M.M it should certainly compile though, yet it doesn't.
– Quentin
Mar 8 '18 at 9:05
1
1
Did not understand why you need this
while (foo() != foo() && (p = 0, true))
, especially (p = 0, true)
part? To test a "trick" and make program less readable? Why not !(p = 0)
instead of (p = 0, true)
?– i486
Mar 8 '18 at 9:13
Did not understand why you need this
while (foo() != foo() && (p = 0, true))
, especially (p = 0, true)
part? To test a "trick" and make program less readable? Why not !(p = 0)
instead of (p = 0, true)
?– i486
Mar 8 '18 at 9:13
|
show 8 more comments
3 Answers
3
active
oldest
votes
I did some experimenting with VC++2017 Preview.
It's definitely a bug bug. It makes it impossible to compile and link code that might be correct, albetit smelly.
A warning would be acceptable. (See @SebastianRedl answer.) But in the latest and greatest VC++2017, it is being treated as an error, not warning, even with warnings turned off, and "Treat warnings as errors" set to No. Something odd is happening. The "error" is being thrown late - after it says, "Generating code". I would guess, and it's only a guess, that the "Generating code" pass is doing global analysis to determine if un-initialized access is possible, and it's getting it wrong. Even then, you should be able to disable the error, IMO.
I do not know if this is new behavior. Reading Sebastian's answer, I presume it is. When I get any kind of warning at any level, I always fix it in the code, so I would not know.
Jesse, click on the triangular flag near the top right of Visual Studio, and report it.
add a comment |
It's kind of a bug, but very typical for the kind of code you write.
First, this isn't an error, it's a warning. C4703 is a level 4 warning (meaning that it isn't even enabled by default). So in order to get it reported as an error (and thus interrupt compilation), compiler arguments or pragmas were passed to enable this warning and turn it into an error (/W4
and /Werror
are the most likely I think).
Then there's a trade-off in the compiler. How complex should the data flow analysis be to determine whether a variable is actually uninitialized? Should it be interprocedural? The more complex it is, the slower the compiler gets (and because of the halting problem, the issue may be undecidable anyway). The simpler it is, the more false positives you get because the condition that guarantees initialization is too complex for the compiler to understand.
In this case, I suspect that the compiler's analysis works as follows: the assignment to p
is behind a conditional (it only happens if foo() != foo()
). The usage of p
is also behind a conditional (it only happens if that complex and-expression is true). The compiler cannot establish a relationship between these conditions (the analysis is not complex enough to realize that foo() != foo()
is a precondition to the entire while loop condition being true). Thus, the compiler errs on the side of assuming that the access could happen without prior initialization and emits the warning.
So it's an engineering trade-off. You could report the bug, but if you do, I suggest you supply a more compelling real-world example of idiomatic code to argue in favor of making the analysis more complex. Are you sure you can't restructure your original code to make it more approachable to the compiler, and more readable for humans at the same time?
I take it back. It's a bug bug, because turning off all warnings does not save the day. It is now a hard error.1>c:usersdavedocumentsvc++ 2017projectsscratchscratch.cpp(81): error C4703: potentially uninitialized local pointer variable 'p' used
Something odd is happening. The "error" is being generated late - perhaps while linking, or maybe duing whole-program optimization.
– Jive Dadson
Mar 8 '18 at 9:12
Ping. It's def. broken. C4703 is reported as an error, not warning. It cannot be disabled. I don't know if this is new behavior or not.
– Jive Dadson
Mar 8 '18 at 9:17
1
@JiveDadson Huh, that's interesting. This warning isn't new; it's documented all the way back to VS2012. Best guess is they rewrote the analysis as part of their compiler refactoring and messed up. In that case, you should definitely report a bug.
– Sebastian Redl
Mar 8 '18 at 9:54
I started to, but I decided it was easier to let Jesse do it.
– Jive Dadson
Mar 8 '18 at 9:55
add a comment |
For sure it's a bug. I tried to remove it in all possible ways, including #pragma. The real thing is that this is reported as an error, not as a warning as Microsoft say. This is a big mistake from Microsoft. It's NOT a WARNING, it's an ERROR. Please, do not repeat again that it's a warning, because it's NOT.
What I'm doing is trying to compile some third party library whose sources I do not want to fix in any way, and should compile in normal cases, but it DOESN'T compile in VS2017 because the infamous "error C4703: potentially uninitialized local pointer variable *** used".
Someone found a solution for that?
1
Hi Rob, this appears to repeat what Jive Dadson wrote 5 months ago. You can't vote for his answer yet (as you're new here) but that's how you can indicate in the future that an existing answer is correct.
– MSalters
Aug 27 '18 at 15:39
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f49168300%2fis-this-a-compiler-bug-in-msvc-2017-update-3%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
I did some experimenting with VC++2017 Preview.
It's definitely a bug bug. It makes it impossible to compile and link code that might be correct, albetit smelly.
A warning would be acceptable. (See @SebastianRedl answer.) But in the latest and greatest VC++2017, it is being treated as an error, not warning, even with warnings turned off, and "Treat warnings as errors" set to No. Something odd is happening. The "error" is being thrown late - after it says, "Generating code". I would guess, and it's only a guess, that the "Generating code" pass is doing global analysis to determine if un-initialized access is possible, and it's getting it wrong. Even then, you should be able to disable the error, IMO.
I do not know if this is new behavior. Reading Sebastian's answer, I presume it is. When I get any kind of warning at any level, I always fix it in the code, so I would not know.
Jesse, click on the triangular flag near the top right of Visual Studio, and report it.
add a comment |
I did some experimenting with VC++2017 Preview.
It's definitely a bug bug. It makes it impossible to compile and link code that might be correct, albetit smelly.
A warning would be acceptable. (See @SebastianRedl answer.) But in the latest and greatest VC++2017, it is being treated as an error, not warning, even with warnings turned off, and "Treat warnings as errors" set to No. Something odd is happening. The "error" is being thrown late - after it says, "Generating code". I would guess, and it's only a guess, that the "Generating code" pass is doing global analysis to determine if un-initialized access is possible, and it's getting it wrong. Even then, you should be able to disable the error, IMO.
I do not know if this is new behavior. Reading Sebastian's answer, I presume it is. When I get any kind of warning at any level, I always fix it in the code, so I would not know.
Jesse, click on the triangular flag near the top right of Visual Studio, and report it.
add a comment |
I did some experimenting with VC++2017 Preview.
It's definitely a bug bug. It makes it impossible to compile and link code that might be correct, albetit smelly.
A warning would be acceptable. (See @SebastianRedl answer.) But in the latest and greatest VC++2017, it is being treated as an error, not warning, even with warnings turned off, and "Treat warnings as errors" set to No. Something odd is happening. The "error" is being thrown late - after it says, "Generating code". I would guess, and it's only a guess, that the "Generating code" pass is doing global analysis to determine if un-initialized access is possible, and it's getting it wrong. Even then, you should be able to disable the error, IMO.
I do not know if this is new behavior. Reading Sebastian's answer, I presume it is. When I get any kind of warning at any level, I always fix it in the code, so I would not know.
Jesse, click on the triangular flag near the top right of Visual Studio, and report it.
I did some experimenting with VC++2017 Preview.
It's definitely a bug bug. It makes it impossible to compile and link code that might be correct, albetit smelly.
A warning would be acceptable. (See @SebastianRedl answer.) But in the latest and greatest VC++2017, it is being treated as an error, not warning, even with warnings turned off, and "Treat warnings as errors" set to No. Something odd is happening. The "error" is being thrown late - after it says, "Generating code". I would guess, and it's only a guess, that the "Generating code" pass is doing global analysis to determine if un-initialized access is possible, and it's getting it wrong. Even then, you should be able to disable the error, IMO.
I do not know if this is new behavior. Reading Sebastian's answer, I presume it is. When I get any kind of warning at any level, I always fix it in the code, so I would not know.
Jesse, click on the triangular flag near the top right of Visual Studio, and report it.
edited Mar 8 '18 at 9:54
answered Mar 8 '18 at 9:27
Jive DadsonJive Dadson
11.5k74259
11.5k74259
add a comment |
add a comment |
It's kind of a bug, but very typical for the kind of code you write.
First, this isn't an error, it's a warning. C4703 is a level 4 warning (meaning that it isn't even enabled by default). So in order to get it reported as an error (and thus interrupt compilation), compiler arguments or pragmas were passed to enable this warning and turn it into an error (/W4
and /Werror
are the most likely I think).
Then there's a trade-off in the compiler. How complex should the data flow analysis be to determine whether a variable is actually uninitialized? Should it be interprocedural? The more complex it is, the slower the compiler gets (and because of the halting problem, the issue may be undecidable anyway). The simpler it is, the more false positives you get because the condition that guarantees initialization is too complex for the compiler to understand.
In this case, I suspect that the compiler's analysis works as follows: the assignment to p
is behind a conditional (it only happens if foo() != foo()
). The usage of p
is also behind a conditional (it only happens if that complex and-expression is true). The compiler cannot establish a relationship between these conditions (the analysis is not complex enough to realize that foo() != foo()
is a precondition to the entire while loop condition being true). Thus, the compiler errs on the side of assuming that the access could happen without prior initialization and emits the warning.
So it's an engineering trade-off. You could report the bug, but if you do, I suggest you supply a more compelling real-world example of idiomatic code to argue in favor of making the analysis more complex. Are you sure you can't restructure your original code to make it more approachable to the compiler, and more readable for humans at the same time?
I take it back. It's a bug bug, because turning off all warnings does not save the day. It is now a hard error.1>c:usersdavedocumentsvc++ 2017projectsscratchscratch.cpp(81): error C4703: potentially uninitialized local pointer variable 'p' used
Something odd is happening. The "error" is being generated late - perhaps while linking, or maybe duing whole-program optimization.
– Jive Dadson
Mar 8 '18 at 9:12
Ping. It's def. broken. C4703 is reported as an error, not warning. It cannot be disabled. I don't know if this is new behavior or not.
– Jive Dadson
Mar 8 '18 at 9:17
1
@JiveDadson Huh, that's interesting. This warning isn't new; it's documented all the way back to VS2012. Best guess is they rewrote the analysis as part of their compiler refactoring and messed up. In that case, you should definitely report a bug.
– Sebastian Redl
Mar 8 '18 at 9:54
I started to, but I decided it was easier to let Jesse do it.
– Jive Dadson
Mar 8 '18 at 9:55
add a comment |
It's kind of a bug, but very typical for the kind of code you write.
First, this isn't an error, it's a warning. C4703 is a level 4 warning (meaning that it isn't even enabled by default). So in order to get it reported as an error (and thus interrupt compilation), compiler arguments or pragmas were passed to enable this warning and turn it into an error (/W4
and /Werror
are the most likely I think).
Then there's a trade-off in the compiler. How complex should the data flow analysis be to determine whether a variable is actually uninitialized? Should it be interprocedural? The more complex it is, the slower the compiler gets (and because of the halting problem, the issue may be undecidable anyway). The simpler it is, the more false positives you get because the condition that guarantees initialization is too complex for the compiler to understand.
In this case, I suspect that the compiler's analysis works as follows: the assignment to p
is behind a conditional (it only happens if foo() != foo()
). The usage of p
is also behind a conditional (it only happens if that complex and-expression is true). The compiler cannot establish a relationship between these conditions (the analysis is not complex enough to realize that foo() != foo()
is a precondition to the entire while loop condition being true). Thus, the compiler errs on the side of assuming that the access could happen without prior initialization and emits the warning.
So it's an engineering trade-off. You could report the bug, but if you do, I suggest you supply a more compelling real-world example of idiomatic code to argue in favor of making the analysis more complex. Are you sure you can't restructure your original code to make it more approachable to the compiler, and more readable for humans at the same time?
I take it back. It's a bug bug, because turning off all warnings does not save the day. It is now a hard error.1>c:usersdavedocumentsvc++ 2017projectsscratchscratch.cpp(81): error C4703: potentially uninitialized local pointer variable 'p' used
Something odd is happening. The "error" is being generated late - perhaps while linking, or maybe duing whole-program optimization.
– Jive Dadson
Mar 8 '18 at 9:12
Ping. It's def. broken. C4703 is reported as an error, not warning. It cannot be disabled. I don't know if this is new behavior or not.
– Jive Dadson
Mar 8 '18 at 9:17
1
@JiveDadson Huh, that's interesting. This warning isn't new; it's documented all the way back to VS2012. Best guess is they rewrote the analysis as part of their compiler refactoring and messed up. In that case, you should definitely report a bug.
– Sebastian Redl
Mar 8 '18 at 9:54
I started to, but I decided it was easier to let Jesse do it.
– Jive Dadson
Mar 8 '18 at 9:55
add a comment |
It's kind of a bug, but very typical for the kind of code you write.
First, this isn't an error, it's a warning. C4703 is a level 4 warning (meaning that it isn't even enabled by default). So in order to get it reported as an error (and thus interrupt compilation), compiler arguments or pragmas were passed to enable this warning and turn it into an error (/W4
and /Werror
are the most likely I think).
Then there's a trade-off in the compiler. How complex should the data flow analysis be to determine whether a variable is actually uninitialized? Should it be interprocedural? The more complex it is, the slower the compiler gets (and because of the halting problem, the issue may be undecidable anyway). The simpler it is, the more false positives you get because the condition that guarantees initialization is too complex for the compiler to understand.
In this case, I suspect that the compiler's analysis works as follows: the assignment to p
is behind a conditional (it only happens if foo() != foo()
). The usage of p
is also behind a conditional (it only happens if that complex and-expression is true). The compiler cannot establish a relationship between these conditions (the analysis is not complex enough to realize that foo() != foo()
is a precondition to the entire while loop condition being true). Thus, the compiler errs on the side of assuming that the access could happen without prior initialization and emits the warning.
So it's an engineering trade-off. You could report the bug, but if you do, I suggest you supply a more compelling real-world example of idiomatic code to argue in favor of making the analysis more complex. Are you sure you can't restructure your original code to make it more approachable to the compiler, and more readable for humans at the same time?
It's kind of a bug, but very typical for the kind of code you write.
First, this isn't an error, it's a warning. C4703 is a level 4 warning (meaning that it isn't even enabled by default). So in order to get it reported as an error (and thus interrupt compilation), compiler arguments or pragmas were passed to enable this warning and turn it into an error (/W4
and /Werror
are the most likely I think).
Then there's a trade-off in the compiler. How complex should the data flow analysis be to determine whether a variable is actually uninitialized? Should it be interprocedural? The more complex it is, the slower the compiler gets (and because of the halting problem, the issue may be undecidable anyway). The simpler it is, the more false positives you get because the condition that guarantees initialization is too complex for the compiler to understand.
In this case, I suspect that the compiler's analysis works as follows: the assignment to p
is behind a conditional (it only happens if foo() != foo()
). The usage of p
is also behind a conditional (it only happens if that complex and-expression is true). The compiler cannot establish a relationship between these conditions (the analysis is not complex enough to realize that foo() != foo()
is a precondition to the entire while loop condition being true). Thus, the compiler errs on the side of assuming that the access could happen without prior initialization and emits the warning.
So it's an engineering trade-off. You could report the bug, but if you do, I suggest you supply a more compelling real-world example of idiomatic code to argue in favor of making the analysis more complex. Are you sure you can't restructure your original code to make it more approachable to the compiler, and more readable for humans at the same time?
answered Mar 8 '18 at 8:55
Sebastian RedlSebastian Redl
50.2k476116
50.2k476116
I take it back. It's a bug bug, because turning off all warnings does not save the day. It is now a hard error.1>c:usersdavedocumentsvc++ 2017projectsscratchscratch.cpp(81): error C4703: potentially uninitialized local pointer variable 'p' used
Something odd is happening. The "error" is being generated late - perhaps while linking, or maybe duing whole-program optimization.
– Jive Dadson
Mar 8 '18 at 9:12
Ping. It's def. broken. C4703 is reported as an error, not warning. It cannot be disabled. I don't know if this is new behavior or not.
– Jive Dadson
Mar 8 '18 at 9:17
1
@JiveDadson Huh, that's interesting. This warning isn't new; it's documented all the way back to VS2012. Best guess is they rewrote the analysis as part of their compiler refactoring and messed up. In that case, you should definitely report a bug.
– Sebastian Redl
Mar 8 '18 at 9:54
I started to, but I decided it was easier to let Jesse do it.
– Jive Dadson
Mar 8 '18 at 9:55
add a comment |
I take it back. It's a bug bug, because turning off all warnings does not save the day. It is now a hard error.1>c:usersdavedocumentsvc++ 2017projectsscratchscratch.cpp(81): error C4703: potentially uninitialized local pointer variable 'p' used
Something odd is happening. The "error" is being generated late - perhaps while linking, or maybe duing whole-program optimization.
– Jive Dadson
Mar 8 '18 at 9:12
Ping. It's def. broken. C4703 is reported as an error, not warning. It cannot be disabled. I don't know if this is new behavior or not.
– Jive Dadson
Mar 8 '18 at 9:17
1
@JiveDadson Huh, that's interesting. This warning isn't new; it's documented all the way back to VS2012. Best guess is they rewrote the analysis as part of their compiler refactoring and messed up. In that case, you should definitely report a bug.
– Sebastian Redl
Mar 8 '18 at 9:54
I started to, but I decided it was easier to let Jesse do it.
– Jive Dadson
Mar 8 '18 at 9:55
I take it back. It's a bug bug, because turning off all warnings does not save the day. It is now a hard error.
1>c:usersdavedocumentsvc++ 2017projectsscratchscratch.cpp(81): error C4703: potentially uninitialized local pointer variable 'p' used
Something odd is happening. The "error" is being generated late - perhaps while linking, or maybe duing whole-program optimization.– Jive Dadson
Mar 8 '18 at 9:12
I take it back. It's a bug bug, because turning off all warnings does not save the day. It is now a hard error.
1>c:usersdavedocumentsvc++ 2017projectsscratchscratch.cpp(81): error C4703: potentially uninitialized local pointer variable 'p' used
Something odd is happening. The "error" is being generated late - perhaps while linking, or maybe duing whole-program optimization.– Jive Dadson
Mar 8 '18 at 9:12
Ping. It's def. broken. C4703 is reported as an error, not warning. It cannot be disabled. I don't know if this is new behavior or not.
– Jive Dadson
Mar 8 '18 at 9:17
Ping. It's def. broken. C4703 is reported as an error, not warning. It cannot be disabled. I don't know if this is new behavior or not.
– Jive Dadson
Mar 8 '18 at 9:17
1
1
@JiveDadson Huh, that's interesting. This warning isn't new; it's documented all the way back to VS2012. Best guess is they rewrote the analysis as part of their compiler refactoring and messed up. In that case, you should definitely report a bug.
– Sebastian Redl
Mar 8 '18 at 9:54
@JiveDadson Huh, that's interesting. This warning isn't new; it's documented all the way back to VS2012. Best guess is they rewrote the analysis as part of their compiler refactoring and messed up. In that case, you should definitely report a bug.
– Sebastian Redl
Mar 8 '18 at 9:54
I started to, but I decided it was easier to let Jesse do it.
– Jive Dadson
Mar 8 '18 at 9:55
I started to, but I decided it was easier to let Jesse do it.
– Jive Dadson
Mar 8 '18 at 9:55
add a comment |
For sure it's a bug. I tried to remove it in all possible ways, including #pragma. The real thing is that this is reported as an error, not as a warning as Microsoft say. This is a big mistake from Microsoft. It's NOT a WARNING, it's an ERROR. Please, do not repeat again that it's a warning, because it's NOT.
What I'm doing is trying to compile some third party library whose sources I do not want to fix in any way, and should compile in normal cases, but it DOESN'T compile in VS2017 because the infamous "error C4703: potentially uninitialized local pointer variable *** used".
Someone found a solution for that?
1
Hi Rob, this appears to repeat what Jive Dadson wrote 5 months ago. You can't vote for his answer yet (as you're new here) but that's how you can indicate in the future that an existing answer is correct.
– MSalters
Aug 27 '18 at 15:39
add a comment |
For sure it's a bug. I tried to remove it in all possible ways, including #pragma. The real thing is that this is reported as an error, not as a warning as Microsoft say. This is a big mistake from Microsoft. It's NOT a WARNING, it's an ERROR. Please, do not repeat again that it's a warning, because it's NOT.
What I'm doing is trying to compile some third party library whose sources I do not want to fix in any way, and should compile in normal cases, but it DOESN'T compile in VS2017 because the infamous "error C4703: potentially uninitialized local pointer variable *** used".
Someone found a solution for that?
1
Hi Rob, this appears to repeat what Jive Dadson wrote 5 months ago. You can't vote for his answer yet (as you're new here) but that's how you can indicate in the future that an existing answer is correct.
– MSalters
Aug 27 '18 at 15:39
add a comment |
For sure it's a bug. I tried to remove it in all possible ways, including #pragma. The real thing is that this is reported as an error, not as a warning as Microsoft say. This is a big mistake from Microsoft. It's NOT a WARNING, it's an ERROR. Please, do not repeat again that it's a warning, because it's NOT.
What I'm doing is trying to compile some third party library whose sources I do not want to fix in any way, and should compile in normal cases, but it DOESN'T compile in VS2017 because the infamous "error C4703: potentially uninitialized local pointer variable *** used".
Someone found a solution for that?
For sure it's a bug. I tried to remove it in all possible ways, including #pragma. The real thing is that this is reported as an error, not as a warning as Microsoft say. This is a big mistake from Microsoft. It's NOT a WARNING, it's an ERROR. Please, do not repeat again that it's a warning, because it's NOT.
What I'm doing is trying to compile some third party library whose sources I do not want to fix in any way, and should compile in normal cases, but it DOESN'T compile in VS2017 because the infamous "error C4703: potentially uninitialized local pointer variable *** used".
Someone found a solution for that?
answered Aug 27 '18 at 15:33
Rob MelRob Mel
111
111
1
Hi Rob, this appears to repeat what Jive Dadson wrote 5 months ago. You can't vote for his answer yet (as you're new here) but that's how you can indicate in the future that an existing answer is correct.
– MSalters
Aug 27 '18 at 15:39
add a comment |
1
Hi Rob, this appears to repeat what Jive Dadson wrote 5 months ago. You can't vote for his answer yet (as you're new here) but that's how you can indicate in the future that an existing answer is correct.
– MSalters
Aug 27 '18 at 15:39
1
1
Hi Rob, this appears to repeat what Jive Dadson wrote 5 months ago. You can't vote for his answer yet (as you're new here) but that's how you can indicate in the future that an existing answer is correct.
– MSalters
Aug 27 '18 at 15:39
Hi Rob, this appears to repeat what Jive Dadson wrote 5 months ago. You can't vote for his answer yet (as you're new here) but that's how you can indicate in the future that an existing answer is correct.
– MSalters
Aug 27 '18 at 15:39
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f49168300%2fis-this-a-compiler-bug-in-msvc-2017-update-3%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
5
Upvoted, but can you give a slightly less convoluted and more motivating example?
– StoryTeller
Mar 8 '18 at 8:13
1
What would you expect?
– Serge Ballesta
Mar 8 '18 at 8:26
1
I don't see how the value of
p
could be accessed before it is initialized. Moreover on the version of MSVC on compiler explorer, the code just compile without error link. Certainly a compiler bug.– Oliv
Mar 8 '18 at 8:34
1
@M.M it should certainly compile though, yet it doesn't.
– Quentin
Mar 8 '18 at 9:05
1
Did not understand why you need this
while (foo() != foo() && (p = 0, true))
, especially(p = 0, true)
part? To test a "trick" and make program less readable? Why not!(p = 0)
instead of(p = 0, true)
?– i486
Mar 8 '18 at 9:13