Commit 1b3f84f967daf9a668a5b1f5337d5d3d96e9112b

Authored by Jay Berkenbilt
1 parent 9fcf61b2

Require C++14 instead of C++11

ChangeLog
1 1 2021-02-10 Jay Berkenbilt <ejb@ql.org>
2 2  
  3 + * Require a C++-14 compiler.
  4 +
3 5 * Detect loops when adding when reading outlines dictionary upon
4 6 initialization of QPDFOutlineDocumentHelper (fuzz issue 30507).
5 7  
... ...
README-maintainer
... ... @@ -4,16 +4,16 @@ ROUTINE DEVELOPMENT
4 4  
5 5 Default:
6 6  
7   -./configure CXX="g++ --std=c++11" --enable-werror
  7 +./configure CXX="g++ --std=c++14" --enable-werror
8 8  
9 9 Debugging:
10 10  
11   -./configure CXX="g++ --std=c++11" CFLAGS="-g" CXXFLAGS="-g" \
  11 +./configure CXX="g++ --std=c++14" CFLAGS="-g" CXXFLAGS="-g" \
12 12 --enable-werror --disable-shared
13 13  
14 14 Profiling:
15 15  
16   -./configure CXX="g++ --std=c++11" CFLAGS="-g -pg" CXXFLAGS="-g -pg" \
  16 +./configure CXX="g++ --std=c++14" CFLAGS="-g -pg" CXXFLAGS="-g -pg" \
17 17 LDFLAGS="-pg" --enable-werror --disable-shared
18 18  
19 19 Then run `gprof gmon.out`. Note that gmon.out is not cumulative.
... ... @@ -23,7 +23,7 @@ Memory checks:
23 23 ./configure CFLAGS="-fsanitize=address -fsanitize=undefined -g" \
24 24 CXXFLAGS="-fsanitize=address -fsanitize=undefined -g" \
25 25 LDFLAGS="-fsanitize=address -fsanitize=undefined" \
26   - CC=clang CXX="clang++ --std=c++11" \
  26 + CC=clang CXX="clang++ --std=c++14" \
27 27 --enable-werror --disable-shared
28 28  
29 29  
... ...
README.md
... ... @@ -28,7 +28,7 @@ Versions of qpdf prior to version 7 were released under the terms of version 2.0
28 28  
29 29 # Prerequisites
30 30  
31   -QPDF requires a C++ compiler that supports C++-11.
  31 +QPDF requires a C++ compiler that supports C++-14.
32 32  
33 33 QPDF depends on the external libraries [zlib](https://www.zlib.net/) and [jpeg](https://www.ijg.org/files/). The [libjpeg-turbo](https://libjpeg-turbo.org/) library is also known to work since it is compatible with the regular jpeg library, and QPDF doesn't use any interfaces that aren't present in the straight jpeg8 API. These are part of every Linux distribution and are readily available. Download information appears in the documentation. For Windows, you can download pre-built binary versions of these libraries for some compilers; see [README-windows.md](README-windows.md) for additional details.
34 34  
... ...
autofiles.sums
1   -acefdeee8c37c7cabad528c8984440d96036da4af81050a02fbcca7a9d3c2922 configure.ac
  1 +715dae6d625977752bf7ddf7e386a2dc6ada04b8e56c6f0e7a3f7dcc9bad3209 configure.ac
2 2 d3f9ee6f6f0846888d9a10fd3dad2e4b1258be84205426cf04d7cef02d61dad7 aclocal.m4
3   -cf2c764639c4c94abc183a0976eca6ae500b80790ea25e3d0af97b23587363b7 libqpdf/qpdf/qpdf-config.h.in
  3 +d12e9b7b928e7b2b9d4ffbc2af170392421376e60e40d07bdeee6a7252be8f6e libqpdf/qpdf/qpdf-config.h.in
4 4 5297971a0ef90bcd5563eb3f7127a032bb76d3ae2af7258bf13479caf8983a60 m4/ax_cxx_compile_stdcxx.m4
5 5 35bc5c645dc42d47f2daeea06f8f3e767c8a1aee6a35eb2b4854fd2ce66c3413 m4/ax_random_device.m4
6 6 1451e63710701b5f00a668f3a79b435015ef2e63547f0ad0ce8c8c062d53b599 m4/libtool.m4
... ...
build-scripts/test-sanitizers
... ... @@ -7,7 +7,7 @@ sudo apt-get -y install \
7 7 CFLAGS="-fsanitize=address -fsanitize=undefined -g" \
8 8 CXXFLAGS="-fsanitize=address -fsanitize=undefined -g" \
9 9 LDFLAGS="-fsanitize=address -fsanitize=undefined" \
10   - CC=clang CXX="clang++ --std=c++11" \
  10 + CC=clang CXX="clang++ --std=c++14" \
11 11 --enable-crypto-native --enable-crypto-openssl --enable-crypto-gnutls \
12 12 --enable-werror --disable-shared --enable-show-failed-test-output
13 13 make -j$(nproc) -k
... ...
configure
... ... @@ -710,7 +710,7 @@ AS
710 710 EGREP
711 711 GREP
712 712 CPP
713   -HAVE_CXX11
  713 +HAVE_CXX14
714 714 ac_ct_CXX
715 715 CXXFLAGS
716 716 CXX
... ... @@ -4055,7 +4055,7 @@ ac_link=&#39;$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $
4055 4055 ac_compiler_gnu=$ac_cv_c_compiler_gnu
4056 4056  
4057 4057  
4058   - ax_cxx_compile_alternatives="11 0x" ax_cxx_compile_cxx11_required=true
  4058 + ax_cxx_compile_alternatives="14 1y" ax_cxx_compile_cxx14_required=true
4059 4059 ac_ext=cpp
4060 4060 ac_cpp='$CXXCPP $CPPFLAGS'
4061 4061 ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
... ... @@ -4068,9 +4068,9 @@ ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
4068 4068 if test x$ac_success = xno; then
4069 4069 for alternative in ${ax_cxx_compile_alternatives}; do
4070 4070 for switch in "" -std=c++${alternative} +std=c++${alternative} "-h std=c++${alternative}"; do
4071   - cachevar=`$as_echo "ax_cv_cxx_compile_cxx11_$switch" | $as_tr_sh`
4072   - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX supports C++11 features with $switch" >&5
4073   -$as_echo_n "checking whether $CXX supports C++11 features with $switch... " >&6; }
  4071 + cachevar=`$as_echo "ax_cv_cxx_compile_cxx14_$switch" | $as_tr_sh`
  4072 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX supports C++14 features with $switch" >&5
  4073 +$as_echo_n "checking whether $CXX supports C++14 features with $switch... " >&6; }
4074 4074 if eval \${$cachevar+:} false; then :
4075 4075 $as_echo_n "(cached) " >&6
4076 4076 else
... ... @@ -4366,6 +4366,126 @@ namespace cxx11
4366 4366  
4367 4367  
4368 4368  
  4369 +
  4370 +// If the compiler admits that it is not ready for C++14, why torture it?
  4371 +// Hopefully, this will speed up the test.
  4372 +
  4373 +#ifndef __cplusplus
  4374 +
  4375 +#error "This is not a C++ compiler"
  4376 +
  4377 +#elif __cplusplus < 201402L && ! defined(_MSC_VER)
  4378 +
  4379 +#error "This is not a C++14 compiler"
  4380 +
  4381 +#else
  4382 +
  4383 +namespace cxx14
  4384 +{
  4385 +
  4386 + namespace test_polymorphic_lambdas
  4387 + {
  4388 +
  4389 + int
  4390 + test()
  4391 + {
  4392 + const auto lambda = [](auto&&... args){
  4393 + const auto istiny = [](auto x){
  4394 + return (sizeof(x) == 1UL) ? 1 : 0;
  4395 + };
  4396 + const int aretiny[] = { istiny(args)... };
  4397 + return aretiny[0];
  4398 + };
  4399 + return lambda(1, 1L, 1.0f, '1');
  4400 + }
  4401 +
  4402 + }
  4403 +
  4404 + namespace test_binary_literals
  4405 + {
  4406 +
  4407 + constexpr auto ivii = 0b0000000000101010;
  4408 + static_assert(ivii == 42, "wrong value");
  4409 +
  4410 + }
  4411 +
  4412 + namespace test_generalized_constexpr
  4413 + {
  4414 +
  4415 + template < typename CharT >
  4416 + constexpr unsigned long
  4417 + strlen_c(const CharT *const s) noexcept
  4418 + {
  4419 + auto length = 0UL;
  4420 + for (auto p = s; *p; ++p)
  4421 + ++length;
  4422 + return length;
  4423 + }
  4424 +
  4425 + static_assert(strlen_c("") == 0UL, "");
  4426 + static_assert(strlen_c("x") == 1UL, "");
  4427 + static_assert(strlen_c("test") == 4UL, "");
  4428 + static_assert(strlen_c("another\0test") == 7UL, "");
  4429 +
  4430 + }
  4431 +
  4432 + namespace test_lambda_init_capture
  4433 + {
  4434 +
  4435 + int
  4436 + test()
  4437 + {
  4438 + auto x = 0;
  4439 + const auto lambda1 = [a = x](int b){ return a + b; };
  4440 + const auto lambda2 = [a = lambda1(x)](){ return a; };
  4441 + return lambda2();
  4442 + }
  4443 +
  4444 + }
  4445 +
  4446 + namespace test_digit_separators
  4447 + {
  4448 +
  4449 + constexpr auto ten_million = 100'000'000;
  4450 + static_assert(ten_million == 100000000, "");
  4451 +
  4452 + }
  4453 +
  4454 + namespace test_return_type_deduction
  4455 + {
  4456 +
  4457 + auto f(int& x) { return x; }
  4458 + decltype(auto) g(int& x) { return x; }
  4459 +
  4460 + template < typename T1, typename T2 >
  4461 + struct is_same
  4462 + {
  4463 + static constexpr auto value = false;
  4464 + };
  4465 +
  4466 + template < typename T >
  4467 + struct is_same<T, T>
  4468 + {
  4469 + static constexpr auto value = true;
  4470 + };
  4471 +
  4472 + int
  4473 + test()
  4474 + {
  4475 + auto x = 0;
  4476 + static_assert(is_same<int, decltype(f(x))>::value, "");
  4477 + static_assert(is_same<int&, decltype(g(x))>::value, "");
  4478 + return x;
  4479 + }
  4480 +
  4481 + }
  4482 +
  4483 +} // namespace cxx14
  4484 +
  4485 +#endif // __cplusplus >= 201402L
  4486 +
  4487 +
  4488 +
4369 4489 _ACEOF
4370 4490 if ac_fn_cxx_try_compile "$LINENO"; then :
4371 4491 eval $cachevar=yes
... ... @@ -4398,19 +4518,19 @@ ac_compile=&#39;$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext &gt;&amp;5&#39;
4398 4518 ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
4399 4519 ac_compiler_gnu=$ac_cv_c_compiler_gnu
4400 4520  
4401   - if test x$ax_cxx_compile_cxx11_required = xtrue; then
  4521 + if test x$ax_cxx_compile_cxx14_required = xtrue; then
4402 4522 if test x$ac_success = xno; then
4403   - as_fn_error $? "*** A compiler with support for C++11 language features is required." "$LINENO" 5
  4523 + as_fn_error $? "*** A compiler with support for C++14 language features is required." "$LINENO" 5
4404 4524 fi
4405 4525 fi
4406 4526 if test x$ac_success = xno; then
4407   - HAVE_CXX11=0
4408   - { $as_echo "$as_me:${as_lineno-$LINENO}: No compiler with C++11 support was found" >&5
4409   -$as_echo "$as_me: No compiler with C++11 support was found" >&6;}
  4527 + HAVE_CXX14=0
  4528 + { $as_echo "$as_me:${as_lineno-$LINENO}: No compiler with C++14 support was found" >&5
  4529 +$as_echo "$as_me: No compiler with C++14 support was found" >&6;}
4410 4530 else
4411   - HAVE_CXX11=1
  4531 + HAVE_CXX14=1
4412 4532  
4413   -$as_echo "#define HAVE_CXX11 1" >>confdefs.h
  4533 +$as_echo "#define HAVE_CXX14 1" >>confdefs.h
4414 4534  
4415 4535 fi
4416 4536  
... ...
configure.ac
... ... @@ -36,7 +36,7 @@ fi
36 36 AC_PROG_CC
37 37 AC_PROG_CC_C99
38 38 AC_PROG_CXX
39   -AX_CXX_COMPILE_STDCXX([11], [noext], [mandatory])
  39 +AX_CXX_COMPILE_STDCXX([14], [noext], [mandatory])
40 40 AC_HEADER_STDC
41 41 LT_INIT([win32-dll])
42 42  
... ...
libqpdf/qpdf/qpdf-config.h.in
... ... @@ -6,8 +6,8 @@
6 6 /* Default crypto provider */
7 7 #undef DEFAULT_CRYPTO
8 8  
9   -/* define if the compiler supports basic C++11 syntax */
10   -#undef HAVE_CXX11
  9 +/* define if the compiler supports basic C++14 syntax */
  10 +#undef HAVE_CXX14
11 11  
12 12 /* Define to 1 if you have the <dlfcn.h> header file. */
13 13 #undef HAVE_DLFCN_H
... ...
manual/qpdf-manual.xml
... ... @@ -118,7 +118,7 @@
118 118 <itemizedlist>
119 119 <listitem>
120 120 <para>
121   - A C++ compiler that supports C++-11.
  121 + A C++ compiler that supports C++-14.
122 122 </para>
123 123 </listitem>
124 124 <listitem>
... ... @@ -5188,6 +5188,21 @@ print &quot;\n&quot;;
5188 5188 </listitem>
5189 5189 <listitem>
5190 5190 <para>
  5191 + Build Changes
  5192 + </para>
  5193 + <itemizedlist>
  5194 + <listitem>
  5195 + <para>
  5196 + A C++-14 compiler is now required to build qpdf. There is no
  5197 + intention to require anything newer than that for a while.
  5198 + C++-14 includes modest enhancements to C++-11 and appears to
  5199 + be supported about as widely as C++-11.
  5200 + </para>
  5201 + </listitem>
  5202 + </itemizedlist>
  5203 + </listitem>
  5204 + <listitem>
  5205 + <para>
5191 5206 Bug Fixes
5192 5207 </para>
5193 5208 <itemizedlist>
... ...