nlohmann / json

JSON for Modern C++
https://json.nlohmann.me
MIT License
41.46k stars 6.59k forks source link

compiler error using clang-16.0.5 when using gcc-13.1 standard library #4051

Open janwilmans opened 1 year ago

janwilmans commented 1 year ago

Description

https://godbolt.org/z/jnxMe6veT

workaround: -DJSON_HAS_RANGES=0

Reproduction steps

na.

Expected vs. actual results

no compilation error vs. compilation error

Minimal code example

#include <nlohmann/json.hpp>
#include <sstream>
#include <iomanip>

using nlohmann::json;

int main()
{
    std::stringstream ss;
    json j = {"foo", 1, 2, 3, false, {{"one", 1}}};
    ss << std::setw(1) << std::setfill('\t') << j;

}

Error messages

In file included from <source>:1:
In file included from /opt/compiler-explorer/libs/nlohmann_json/trunk/single_include/nlohmann/json.hpp:5097:
/opt/compiler-explorer/gcc-13.1.0/lib/gcc/x86_64-linux-gnu/13.1.0/../../../../include/c++/13.1.0/ranges:6151:14: error: requires clause differs in template redeclaration
    requires forward_range<_Vp>
             ^
/opt/compiler-explorer/gcc-13.1.0/lib/gcc/x86_64-linux-gnu/13.1.0/../../../../include/c++/13.1.0/ranges:5850:14: note: previous template declaration is here
    requires input_range<_Vp>
             ^
/opt/compiler-explorer/gcc-13.1.0/lib/gcc/x86_64-linux-gnu/13.1.0/../../../../include/c++/13.1.0/ranges:8846:20: error: type-id cannot have a name
    { return (auto(__x) += __y); }
                   ^
/opt/compiler-explorer/gcc-13.1.0/lib/gcc/x86_64-linux-gnu/13.1.0/../../../../include/c++/13.1.0/ranges:8846:25: error: expected ')'
    { return (auto(__x) += __y); }
                        ^
/opt/compiler-explorer/gcc-13.1.0/lib/gcc/x86_64-linux-gnu/13.1.0/../../../../include/c++/13.1.0/ranges:8846:14: note: to match this '('
    { return (auto(__x) += __y); }
             ^
/opt/compiler-explorer/gcc-13.1.0/lib/gcc/x86_64-linux-gnu/13.1.0/../../../../include/c++/13.1.0/ranges:8846:32: error: expected expression
    { return (auto(__x) += __y); }
                               ^
4 errors generated.
ASM generation compiler returned: 1
In file included from <source>:1:
In file included from /opt/compiler-explorer/libs/nlohmann_json/trunk/single_include/nlohmann/json.hpp:5097:
/opt/compiler-explorer/gcc-13.1.0/lib/gcc/x86_64-linux-gnu/13.1.0/../../../../include/c++/13.1.0/ranges:6151:14: error: requires clause differs in template redeclaration
    requires forward_range<_Vp>
             ^
/opt/compiler-explorer/gcc-13.1.0/lib/gcc/x86_64-linux-gnu/13.1.0/../../../../include/c++/13.1.0/ranges:5850:14: note: previous template declaration is here
    requires input_range<_Vp>
             ^
/opt/compiler-explorer/gcc-13.1.0/lib/gcc/x86_64-linux-gnu/13.1.0/../../../../include/c++/13.1.0/ranges:8846:20: error: type-id cannot have a name
    { return (auto(__x) += __y); }
                   ^
/opt/compiler-explorer/gcc-13.1.0/lib/gcc/x86_64-linux-gnu/13.1.0/../../../../include/c++/13.1.0/ranges:8846:25: error: expected ')'
    { return (auto(__x) += __y); }
                        ^
/opt/compiler-explorer/gcc-13.1.0/lib/gcc/x86_64-linux-gnu/13.1.0/../../../../include/c++/13.1.0/ranges:8846:14: note: to match this '('
    { return (auto(__x) += __y); }
             ^
/opt/compiler-explorer/gcc-13.1.0/lib/gcc/x86_64-linux-gnu/13.1.0/../../../../include/c++/13.1.0/ranges:8846:32: error: expected expression
    { return (auto(__x) += __y); }
                               ^
4 errors generated.
Execution build compiler returned: 1

Compiler and operating system

Linux, clang-16.0.5+gcc-13.1 standard library

Library version

3.11.2

Validation