googletest
googletest copied to clipboard
gmock-actions: suppress warning about unreachable code
MSVC warns about unreachable code in BuiltInDefaultValueGetter::Get
.
The C4702
warning has been disabled globally in the GoogleTest project itself
but might pop up in downstream code.
Could you please identify the specific codepaths that trigger this warning? We would prefer to fix those instead of disabling it.
The warning is disabled now, but we would prefer to re-enable it if possible.
It's there and already contains a related comment: https://github.com/google/googletest/blob/bea621c3c39d8a7f71f07bd543c3a58bfa684f92/googlemock/include/gmock/gmock-actions.h#L178-L184
I guess MSVC somehow figures out that Assert(false, ...)
leads to Abort
which is annotated with [[noreturn]]
. All following code like return Invalid<T>()
would be unreachable.
Thanks for the explanation and sorry for the delayed response. Given that this is already disabled globally for the project, we would prefer not to add additional handling related to this warning. Given that different compilers have different behaviors regarding specification of return types in these circumstances, turning off the warning globally as we have done is the best solution. I realize this isn't ideal if someone reenables the warning of their own project, but I don't think we can manage to generally support all of these sorts of warnings in our headers.