Repository navigation
Closed
Labels
Description
Using the new CppCoreCheck tool on a project containing just a single source file including gsl.h and defining main, I get these warnings:
string_span.h(112): warning C26493: Don't use C-style casts that would perform a static_cast downcast, const_cast, or reinterpret_cast. (type.4: http://go.microsoft.com/fwlink/p/?LinkID=620420)
string_span.h(114): warning C26491: Don't use static_cast downcasts. Use dynamic_cast instead. (type.2: http://go.microsoft.com/fwlink/p/?LinkID=620418)
string_span.h(113): warning C26481: Don't use pointer arithmetic. Use span instead. (bounds.1: http://go.microsoft.com/fwlink/p/?LinkID=620413)
string_span.h(120): warning C26491: Don't use static_cast downcasts. Use dynamic_cast instead. (type.2: http://go.microsoft.com/fwlink/p/?LinkID=620418)
string_span.h(120): warning C26481: Don't use pointer arithmetic. Use span instead. (bounds.1: http://go.microsoft.com/fwlink/p/?LinkID=620413)
string_span.h(125): warning C26493: Don't use C-style casts that would perform a static_cast downcast, const_cast, or reinterpret_cast. (type.4: http://go.microsoft.com/fwlink/p/?LinkID=620420)
string_span.h(126): warning C26491: Don't use static_cast downcasts. Use dynamic_cast instead. (type.2: http://go.microsoft.com/fwlink/p/?LinkID=620418)
string_span.h(126): warning C26481: Don't use pointer arithmetic. Use span instead. (bounds.1: http://go.microsoft.com/fwlink/p/?LinkID=620413)
string_span.h(132): warning C26491: Don't use static_cast downcasts. Use dynamic_cast instead. (type.2: http://go.microsoft.com/fwlink/p/?LinkID=620418)
string_span.h(132): warning C26481: Don't use pointer arithmetic. Use span instead. (bounds.1: http://go.microsoft.com/fwlink/p/?LinkID=620413)
span.h(1254): warning C26495: Variable 'gsl::span<wchar_t const ,-1>::bounds_' is uninitialized. Always initialize a member variable. (type.6: http://go.microsoft.com/fwlink/p/?LinkID=620422)
span.h(1254): warning C26485: Expression 'allotemp.2': No array to pointer decay. (bounds.3: http://go.microsoft.com/fwlink/p/?LinkID=620415)
span.h(626): warning C26495: Variable 'gsl::static_bounds<-1>::m_ranges' is uninitialized. Always initialize a member variable. (type.6: http://go.microsoft.com/fwlink/p/?LinkID=620422)
span.h(356): warning C26481: Don't use pointer arithmetic. Use span instead. (bounds.1: http://go.microsoft.com/fwlink/p/?LinkID=620413)
This is using the current version of GSL and CppCoreCheck available through NuGet (0.01 and 14.0.23107.2 respectively).
I'd expect GSL itself to trigger no warnings :) Early days I know but someone should report it! I'm not sure how valid they are so perhaps they just need suppressing.
Activity
neilmacintosh commentedon Dec 8, 2015
Actually, GSL is likely to trigger warnings as it does things that the guidelines tell you not to do, so that you don't have to. :-) However, I think your point is really: you shouldn't hear about those warnings - they are up to GSL developers to consider and then suppress as by-design (or fix if not). I agree completely and we will be adding suppressions where appropriate now that the tools are released.
hymerman commentedon Dec 9, 2015
You're absolutely right Neil, that's what I meant - thanks for looking at this!
neilmacintosh commentedon Dec 15, 2015
Anna Gringauze (@annagrin), do you want to take a look at these?
annagrin commentedon Jan 18, 2019
fixed in #703