Skip to content

GCC 10: Compilation error when including any before including json header in C++17 mode #2129

Description

@gracicot

What is the issue you have?

A compilation error just including parts of the standard library and this library in a specific order when using C++17 and GCC 10.

Please describe the steps to reproduce the issue.

Consider the following file:

#include <any>
#include <nlohmann/json>

When compiling it in C++17 mode, it won't compile with GCC 10

Here's a compile explorer link that shows the issue.

When changing <any> to <variant>, there is no issue. I don't know if any other standard header causes this bug.

When putting the #include <any> after #include <nlohmann/json>, it compiles. DEMO.

What is the expected behavior?

It should compile.

And what is the actual behavior instead?

It shows very strange errors and fail to compile.

Which compiler and operating system are you using?

  • Compiler: GCC 10
  • Operating system: Arch Linux

Which version of the library did you use?

  • latest release version 3.7.3
  • other release - please state the version: ___
  • the develop branch

If you experience a compilation error: can you compile and run the unit tests?

  • yes
  • no - please copy/paste the error message below

I had issues with some CMake related tests but it seem unrelated to this bug.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions