Re: configure adds -std=gnu++11 to CXX variable
Paul Eggert <[email protected]> Mon, 27 May 2024 12:04:40 -0700
| Newsgroups | gmane.comp.sysutils.autoconf.general,gmane.comp.gcc.devel |
|---|---|
| Organization | UCLA Computer Science Department |
| Message-ID | <[email protected]> |
On 2024-05-27 03:35, Florian Weimer wrote:
> Does this turn on experimental language modes by default? That's
> probably not what we want.
What do C++ developers want these days? Autoconf should have a
reasonable default, and C++11 is surely not a good default anymore.
It would be easy to discourage use of C++23 in the near future by using
a stricter test, such as the attached patch (which I've not installed).
Even GCC 14.1 fails the test in the new patch, so 'configure' will fall
back on C++20. I hope GCC 15 will succeed on it but of course there's no
guarantee. Although this new test covers a DR and is not specific to
C++23 (and there seems to be some reluctance to implement the DR, I
assume because it invalidates some older code), I expect any compiler
passing both this and the __cplusplus>=202302 check would be good enough.
Would this patch be preferable to the current Autoconf master?
> It would be better to have an option to raise the C++ mode to at least a
> certain revision, and otherwise use the default.
That option is already available. For example, a builder who doesn't
want C++23 can use './configure ac_cv_prog_cxx_cxx23=no', and a
developer can discourage C++23 by putting ': ${ac_cv_prog_cxx_cxx23=no}'
early in configure.ac.
As I mentioned earlier, I volunteered to document this sort of thing if
Zack doesn't come up with something nicer soon.
0001-Add-P1787R6-test-to-AC_PROG_CXX-C-23-check.patch
(text/x-patch, 1.2 KB)
From b2f28ce66ea1618b50e14085059ce512d7245300 Mon Sep 17 00:00:00 2001 From: Paul Eggert <[email protected]> Date: Mon, 27 May 2024 11:56:06 -0700 Subject: [PATCH] Add P1787R6 test to AC_PROG_CXX C++23 check * lib/autoconf/c.m4 (_AC_CXX_CXX23_TEST_PROGRAM): Check more carefully for C++23 support, by checking for P1787R6, which even GCC 14.1 and Clang 18.1 have not implemented. --- lib/autoconf/c.m4 | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/lib/autoconf/c.m4 b/lib/autoconf/c.m4 index a0a2b487..157dcb12 100644 --- a/lib/autoconf/c.m4 +++ b/lib/autoconf/c.m4 @@ -2856,6 +2856,19 @@ AC_DEFUN([_AC_CXX_CXX23_TEST_PROGRAM], # error "Compiler does not advertise C++23 conformance" #endif +/* Check support for P1787R6: Declarations and where to find them + <https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2020/p1787r6.html>. + See <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98939#c9>. */ +template <typename T> struct A { + void f(int); + template <typename U> void f(U); +}; +template <typename T> struct B { + template <typename T2> struct C { }; +}; +template <typename T, template <typename X> class TT = T::C> struct E { }; +E<B<int> > db; + int main () { -- 2.45.1