Skip to content

GSL_SUPPRESS raises unknown attribute warnings on Intel C++ Compiler #903

@TManhente

Description

@TManhente

When using Intel C++ Compiler on Windows, I got the following warnings (handled as errors on my project):

gsl/span(301): error #3924: attribute namespace "gsl" is unrecognized
          GSL_SUPPRESS(bounds.1) // NO-FORMAT: attribute
          ^

gsl/span(301): remark #1292: unknown attribute "gsl::suppress"
          GSL_SUPPRESS(bounds.1) // NO-FORMAT: attribute
          ^

It seems that the problem lies in the GSL_SUPPRESS() macro definition:

// gsl_assert, l. 45-53 (also in gsl_bype):
#if defined(__clang__)
#define GSL_SUPPRESS(x) [[gsl::suppress("x")]]
#else
#if defined(_MSC_VER) 
#define GSL_SUPPRESS(x) [[gsl::suppress(x)]]
#else
#define GSL_SUPPRESS(x)
#endif // _MSC_VER
#endif // __clang__

Intel C++ compiler defines the _MSC_VER macro on Windows, so it falls into the second #define case.

Perhaps it could be changed to something like

#if defined(_MSC_VER) && ! defined(__INTEL_COMPILER)
#define GSL_SUPPRESS(x) [[gsl::suppress(x)]]

to avoid such warnings.

My test environment:

  • Intel C++ Compiler 19.1.2
  • MSVC 19.26

Metadata

Metadata

Assignees

No one assigned

    Labels

    Good First IssueSuitable for newcomersHelp WantedNeeds additional help or expertise

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions