https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103805

            Bug ID: 103805
           Summary: Inconsistent exception specifications
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: mar...@mpa-garching.mpg.de
  Target Milestone: ---

I'm not really sure how to report this one properly, so please let me know if
crucial information is missing!

It seems that some functions in the libstdc++ header files shipped with g++
11.2.0 have inconsistent exception specification fora few functions. g++ itself
doesn't seem to care, but clang++-13 is unhappy, providing the error message:

clang-13 -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g
-fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -g
-fstack-protector-strong -Wformat -Werror=format-security -Wdate-time
-D_FORTIFY_SOURCE=2 -fPIC -DPKGNAME=ducc0 -DPKGVERSION=0.22.0 -I. -I./src/
-I/home/martin/.local/lib/python3.9/site-packages/pybind11/include
-I/home/martin/.local/lib/python3.9/site-packages/pybind11/include
-I/usr/include/python3.9 -c python/ducc.cc -o
build/temp.linux-x86_64-3.9/python/ducc.o -std=c++17 -fvisibility=hidden -g0
-ffast-math -O3 -march=native -Wfatal-errors -Wfloat-conversion -W -Wall
-Wstrict-aliasing -Wwrite-strings -Wredundant-decls -Woverloaded-virtual
-Wcast-qual -Wcast-align -Wpointer-arith -pthread
In file included from python/ducc.cc:12:
In file included from ./python/fft_pymod.cc:41:
In file included from
/home/martin/.local/lib/python3.9/site-packages/pybind11/include/pybind11/stl.h:21:
/usr/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/valarray:1215:5:
fatal error: exception specification in declaration does not match previous
declaration
    begin(valarray<_Tp>& __va) noexcept
    ^
/usr/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/bits/range_access.h:107:31:
note: previous declaration is here
  template<typename _Tp> _Tp* begin(valarray<_Tp>&);
                              ^

At first glance, clang seems to be perfectly right in complaining about this,
but I'm not sure how much libstdc++ is supposed to be interoperable with other
compilers.

Anyway, if the C++ standard mandates that all declarations have the same
exception specification and g++ just doesn't enforce this at the moment, it
might still be good to update the headers to be more future-proof.

Reply via email to