Skip to content

gsl::suppress issues collected: Strings, literals, cases #2178

Closed

Description

@hsutter

We have a collection of related open issues asking about the GSL [[gsl::suppress(tag)]] syntax:
- #1173
- #1799
- #2042
- #2043
- #2044
- #2046

We should resolve these now that we are writing standards papers proposing to standardize this syntax.

Status quo suppress syntax summary

The current general syntax is:

[[gsl::suppress( tag, justification:"message" )]]

Currently the Guidelines support only suppressing an individual rule (e.g., [[gsl::suppress(C.160)]]) or one of the three profiles type, bounds, and lifetime (e.g., [[gsl::suppress(bounds)]]).

Categorized open issues

The open issues are:

Suggestion for discussion

I think the core change we need is to make the syntax grammatical, to make it more portable (including to follow existing practice) and suitable for standardization:

  • make the tag a string literal
  • make the justification just a string literal

So the syntax would be:

[[gsl::suppress( "tag", "justification message" )]]

which is more proposable for standardization as:

[[suppress( "tag", "justification message" )]]

We should also fix the #tag anchors so they are in fact linkable by tools.

It seems like numbering the Enforcements of each rule would be useful.

I don't think we need to support suppressing a rule by its anchor name (those names are primarily for tools to link to the Guidelines, not for users to refer to in code) or suppressing groups of rules other than the safety profiles. I think the status quo is sufficient, to suppress a single rule by its name (e.g., C.134) and the three safety profiles by name (e.g., bounds).

ETA Bonus question: Should the "tag" allow a comma- and/or whitespace-delimited list that ignores whitespace, such as [[suppress( "type_safety, bounds_safety", "justification message")]] or [[suppress( "type_safety bounds_safety", "justification message")]] ?

Activity

  1. hsutter commented on Feb 15, 2024

    @hsutter
    ContributorAuthor

    Editors call:

    • tag should be "tag" as string literals, not std::strings or string_views, and:
      • a tag that is not a valid existing rule name should be rejected (e.g., reject an HTML link)
      • individual Enforcements cannot be suppressed (a guideline's Enforcements go together)
    • allow only one suppress tag at a time, not a series of names and not a group
    • keep justification:"string-literal" as is
    • tools are encouraged to link to displayable form, and we will look into adding short names like #i13
  2. hsutter commented on Feb 15, 2024

    @hsutter
    ContributorAuthor

    All edits have been applied and other issues closed, so this can now be closed.

  3. self-assigned this
    on Feb 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions