Skip to content

Make tag in gsl::suppress(tag) be a string literal #2042

Closed

Description

@dmitrykobets-msft

The current specification In.force: Enforcement explicitly requires "message" in [[gsl::suppress(tag, justification: "message")]] to be a string literal, but doesn't require tag to be a string literal i.e., [[gsl::suppress("tag", justification: "message")]].

If tag were a string literal, then parsing it would not lose any information. Otherwise, parsing has limitations (https://eel.is/c%2B%2Bdraft/dcl.attr), for instance treating the .11 inside gsl::suppress(R.11) as a floating point literal 0.110000.

Clang already requires tag to be a string, rejecting something like [[gsl::suppress(R.11)]], requiring [[gsl::suppress("R.11")]]. The current GSL implementation therefore needs to special-case this:

//
// make suppress attributes parse for some compilers
// Hopefully temporary until suppression standardization occurs
//
#if defined(__clang__)
#define GSL_SUPPRESS(x) [[gsl::suppress("#x")]]
#else
#if defined(_MSC_VER) && !defined(__INTEL_COMPILER) && !defined(__NVCC__)
#define GSL_SUPPRESS(x) [[gsl::suppress(x)]]
#else
#define GSL_SUPPRESS(x)
#endif // _MSC_VER
#endif // __clang__

Activity

  1. hsutter commented on Jul 27, 2023

    @hsutter
    Contributor

    Editors call: We will consider this in connection with #2044 and #2048.

  2. hsutter commented on Feb 15, 2024

    @hsutter
    Contributor

    Editors call: We agree, it should be a string literal. We'll fix the Guidelines to show that.

  3. self-assigned this
    on Feb 15, 2024
  4. added a commit that references this issue on Feb 15, 2024
    1b37b50
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