Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like a bug in MSVC because
name
is used in the line above. I recommend reporting to Microsoft.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think so: if the control flow in an instantiation of
reaches line 2449, then both
if constexpr
statements before were evaluated as false and their first (in this case: only) substatements become so called discarded statements [stmt.if]/2 which leave no use ofname
in that template specialization.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like it was also discussed on Microsoft Developer Community, and resulted in joining the other compilers (GCC and Clang, at least) for these cases.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for both links!
Regarding the supposed GCC bug: the original poster gave a wrong description of the nature of the problem. He was missing the difference between a runtime
if
and a compile-timeif constexpr
as layed out in the standard. And "This is a valid program which should not produce a warning" misses the point of-Wunused-but-set-parameter
explicitly requesting a warning.This is exactly what the last poster on MS DevCon is rightfully complaining about.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've referenced this PR on DevCon. According to my knowledge of the release schedule this will certainly not make it for 16.10 which will probably be around for a long time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, whatever is preferred here. It's just the same as a few lines later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for investigating and I'm glad that this nonsense has already been reported. Merged this as a workaround for now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I disagree, using a parameter in one branch of
if constexpr
is not conceptually different from using it in one branch ofif
(that may be optimized away). It's great that it was fixed in GCC.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The "misses" is referring to the blanket statement. A valid program may have many good reasons to issue warnings.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, that is true.