Skip to content

in_place_t.h produces a compiler warning when built with C++14 due to use of C++17 inline variable feature #589

@mrkita

Description

@mrkita

When compiling with gcc on eastl 3.27.00, I run into a warning when "include/EASTL/internal/in_place_t.h" is included in any compilation unit.

The warning states:
eastl/include/EASTL/internal/in_place_t.h:29:9: warning: inline variables are only available with '-std=c++17' or '-std=gnu++17' [-Wc++17-extensions]
29 | inline constexpr in_place_t in_place{};

Given that in_place_t is part of the code base not guarded with compiler traits for C++17 or great, I would expect this code to compile without warning.

This warning disappears if "inline" is removed from the corresponding warning line so that the line reads "constexpr in_place_t in_place{};".

From my understanding and testing, this "inline" is not strictly necessary as the variable is marked "constexpr". Without "inline" the variable will be copied uniquely in each separate software translation unit with internal linkage.

This is I understand a potential optimization topic, but given the lack of "inline variables", this does not matter for C++14.

I will have a PR soon with a suggested fix that I hope matches the style of other protected compiler trait features.

Metadata

Metadata

Assignees

No one assigned

    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