Skip to content

[BUG] Passing -pedantic -Werror but relying on extensions #2057

@AaronBallman

Description

@AaronBallman

The build script passes -pedantic -Werror:

add_cxx_compiler_flag(-pedantic)

However, the code relies on extensions:

#if defined(__COUNTER__) && (__COUNTER__ + 1 == __COUNTER__ + 0)

While working on implementing __COUNTER__ for C2y mode in Clang (llvm/llvm-project#162662), I've added the expected extension and pre-compat warnings, which then cause the code in benchmark.h to fail to compile because of -pedantic-errors.

There's a few ways to solve this, but I'm not familiar enough with benchmark to know which is the best way to go. You could stop using __COUNTER__ entirely and just use the __LINE__ fallback since that has to work to be a useful fallback anyway. You could stop passing -pedantic and continuing using __COUNTER__. You could use __extension__ to silence the extension warning. Other ideas likely exist.

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