From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 7597D39C2457; Wed, 4 Nov 2020 17:28:36 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7597D39C2457 From: "federico.kircheis at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c/66918] Disable "inline function declared but never defined" warning Date: Wed, 04 Nov 2020 17:28:36 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c X-Bugzilla-Version: 5.0 X-Bugzilla-Keywords: diagnostic X-Bugzilla-Severity: normal X-Bugzilla-Who: federico.kircheis at gmail dot com X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: cc Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 04 Nov 2020 17:28:36 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D66918 Federico Kircheis changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |federico.kircheis at gmail= dot com --- Comment #9 from Federico Kircheis = --- 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", ma= ybe GCC could adopt the same switch?=