ROOT Version: 6.26/06
Platform: x86-64 Linux (x86-64 Ubuntu 22.04.1)
Compiler: gcc 12.0.1 20220319 (experimental) [master r12-7719-g8ca61ad148f] (Ubuntu 12-20220319-1ubuntu1)
I’m trying to compile a code depending on ROOT with gcc-12 on Ubuntu 22.04.1. The ROOT distribution I used was the pre-built binary compiled by gcc-11 for Ubuntu 22.
In the ROOT header ROOT/RangeCast.hxx, at line 188 and line 227, gcc-12 reported that the reference to std::span is ambiguous. The ambiguousness is raised from std::span (in gcc-12 standard header span) and std::__ROOT::span (at ROOT/span.hxx:155).
Here is the typical output:
In file included from ${ROOT_DIR}/include/TGeoManager.h:20:
In file included from ${ROOT_DIR}/include/TObjArray.h:25:
In file included from ${ROOT_DIR}/include/TSeqCollection.h:25:
In file included from ${ROOT_DIR}/include/TCollection.h:33:
${ROOT_DIR}/include/ROOT/RRangeCast.hxx:188:16: error: reference to 'span' is ambiguous
return std::span<U>(arr, arr + N);
^
/usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/span:104:11: note: candidate found by name lookup is 'std::span'
class span
^
${ROOT_DIR}/include/ROOT/span.hxx:155:7: note: candidate found by name lookup is 'std::__ROOT::span'
class span {
^
In file included from ${ROOT_DIR}/include/TChain.h:24:
In file included from ${ROOT_DIR}/include/TTree.h:36:
In file included from ${ROOT_DIR}/include/TClass.h:29:
In file included from ${ROOT_DIR}/include/TObjArray.h:25:
In file included from ${ROOT_DIR}/include/TSeqCollection.h:25:
In file included from ${ROOT_DIR}/include/TCollection.h:33:
${ROOT_DIR}/include/ROOT/RRangeCast.hxx:186:27: error: reference to 'span' is ambiguous
RRangeCast<T, false, std::span<U>> RangeStaticCast(U (&arr)[N])
^
/usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/span:104:11: note: candidate found by name lookup is 'std::span'
class span
^
${ROOT_DIR}/include/ROOT/span.hxx:155:7: note: candidate found by name lookup is 'std::__ROOT::span'
class span {
^
Compiling on gcc-11 is all right. I wonder why this error occurred in gcc-12 but not in earlier versions, since there is std::span after gcc-10. Perhaps those standard headers have not included span before. Anyway, I report it here.