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

Federico Kircheis <federico.kircheis at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |federico.kircheis at gmail dot 
com

--- Comment #9 from Federico Kircheis <federico.kircheis at gmail dot com> ---
Hello,

I stumbled on this warning too, and would really like to disable it.

Having a defined but not implemented function can help to detect errors at
compile time since c++11, for example consider


----
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wundefined-inline"
constexpr int stop_compilation();
#pragma GCC diagnostic pop

constexpr int foo(int i){
   return is_not_valid(i) ? stop_compilation() : i+42;
}
----


thanks to `stop_compilation()`, we force the user to use foo in a constexpr
context, and we can validate the parameter.

The code works as intended with GCC, MSVC and clang(!).


Rewriting the code as

----
constexpr int foo(int i){
   return is_not_valid(i) ? throw 42 : i+42;
}
----

makes `foo` usable in a non-constexpr context.

In clang it is possible to ignore the warning with "-Wundefined-inline", maybe
GCC could adopt the same switch?

Reply via email to