Date: Fri, 23 Aug 2024 10:09:28 +0200
Hi!
Feels like I am spamming this mailing list, please tell me if you think
that I throw ideas at you at a too immature phase...
But I just recently got a compilation error when running my code through
gcc after it been developed with MSVC about noexcept-specifier (or rather
lack-of).
It is about the std::exception::what() in this case, that is marked with
`noexcept` with GNU c++ library, but not with MSVC:s (2022) library. I
solved the issue for now by using the noexcept-operator, doing
`noexcept(noexcept(std::exception::what()))`, but I think that a nice
syntax that could be used in such cases are `noexcept(override)` to "copy"
the exception specifier of the overridden function (yet again, maybe MSVC
should not issue a warning if the overriding function has a more relaxed
exception specifier than that of the overridden function).
I also think that a `noexcept(auto)` or just simply having an implicit
noexcept on inline/constexpr function if all calls inside the function are
noexcept would be nice to have as well, due to the fact that sometimes we
do specific stuff based upon the exception specifier to have certain
exception guarantees that we can skip if everything we are dependent on is
noexcept. The compiler should be able to check all operations and
function-calls inside a function to determine what exception specification
could be used, where we can specify things manually if we somehow can make
certain guarantees as well.
// Robin
Feels like I am spamming this mailing list, please tell me if you think
that I throw ideas at you at a too immature phase...
But I just recently got a compilation error when running my code through
gcc after it been developed with MSVC about noexcept-specifier (or rather
lack-of).
It is about the std::exception::what() in this case, that is marked with
`noexcept` with GNU c++ library, but not with MSVC:s (2022) library. I
solved the issue for now by using the noexcept-operator, doing
`noexcept(noexcept(std::exception::what()))`, but I think that a nice
syntax that could be used in such cases are `noexcept(override)` to "copy"
the exception specifier of the overridden function (yet again, maybe MSVC
should not issue a warning if the overriding function has a more relaxed
exception specifier than that of the overridden function).
I also think that a `noexcept(auto)` or just simply having an implicit
noexcept on inline/constexpr function if all calls inside the function are
noexcept would be nice to have as well, due to the fact that sometimes we
do specific stuff based upon the exception specifier to have certain
exception guarantees that we can skip if everything we are dependent on is
noexcept. The compiler should be able to check all operations and
function-calls inside a function to determine what exception specification
could be used, where we can specify things manually if we somehow can make
certain guarantees as well.
// Robin
Received on 2024-08-23 08:09:54