Skip to content

Several warnings reported in GSL code by CppCoreCheck tool #220

Closed

Description

@hymerman

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

  1. neilmacintosh commented on Dec 8, 2015

    @neilmacintosh
    Contributor

    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.

  2. hymerman commented on Dec 9, 2015

    @hymerman
    Author

    You're absolutely right Neil, that's what I meant - thanks for looking at this!

  3. neilmacintosh commented on Dec 15, 2015

    @neilmacintosh
    Contributor

    Anna Gringauze (@annagrin), do you want to take a look at these?

  4. added
    Help Wanted
    Good First Issue
    on Apr 19, 2018
  5. annagrin commented on Jan 18, 2019

    @annagrin

    fixed in #703

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Good First IssueHelp Wanted

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions