Closed beinhaerter closed 2 years ago
Hi @beinhaerter I'll look into this. By the way, does the warning get suppressed if you add it right before the narrow cast, instead of before the function definition?
Update:
I tried it myself and I can't find a way to suppress the warning using GSL_SUPPRESS. That appears to be a VS bug, which I'll follow up on. GSL_SUPPRESS should be the method of suppression in this case.
And yes this warning should be suppressed in this context, for the same reason that the const T t = narrow_cast<T>(u);
in the definition of gsl::narrow
has warning suppressions (see https://github.com/microsoft/GSL/issues/786)
Closing this since suppressing es.46 will be fixed in VS 17.3, and the suppression was added the latest PR on this issue
When calling
gsl::narrow<double>(size_t)
under VS 16.11.10 I get the warningIt looks like this warning should be suppressed inside
gsl::narrow
andgsl::narrow_cast
.When adding
GSL_SUPPRESS(es.46) // NO-FORMAT: attribute
to both functions directly after the already existingGSL_SUPPRESS(f.6)
I still get the warning.Is this something that the VS team should look at? Is this a warning that we want to suppress in the GSL? If so, with
GSL_SUPPRESS
or with#pragma warning(disable: ...)
as a workaround?