[MDEV-26443] The check HAVE_C99_INITIALIZERS is not applicable to C++ Created: 2021-08-20  Updated: 2021-08-24  Resolved: 2021-08-20

Status: Closed
Project: MariaDB Server
Component/s: Storage Engine - InnoDB
Affects Version/s: 10.2, 10.3, 10.4, 10.5, 10.6
Fix Version/s: 10.2.41, 10.3.32, 10.4.22, 10.5.13, 10.6.5

Type: Bug Priority: Major
Reporter: Marko Mäkelä Assignee: Marko Mäkelä
Resolution: Fixed Votes: 0
Labels: upstream


 Description   

I think that we should remove the following, rather useless, compile-time check:

diff --git a/storage/innobase/innodb.cmake b/storage/innobase/innodb.cmake
index e2e74951f67..b6276f73e31 100644
--- a/storage/innobase/innodb.cmake
+++ b/storage/innobase/innodb.cmake
@@ -228,11 +228,6 @@ ENDIF(NOT MSVC)
 
 CHECK_FUNCTION_EXISTS(vasprintf  HAVE_VASPRINTF)
 
-CHECK_CXX_SOURCE_COMPILES("struct t1{ int a; char *b; }; struct t1 c= { .a=1, .b=0 }; main() { }" HAVE_C99_INITIALIZERS)
-IF(HAVE_C99_INITIALIZERS)
-  ADD_DEFINITIONS(-DHAVE_C99_INITIALIZERS)
-ENDIF()
-
 SET(MUTEXTYPE "event" CACHE STRING "Mutex type: event, sys or futex")
 
 IF(MUTEXTYPE MATCHES "event")

The test program fails to declare a return type, so it should hopefully always fail to compile with a C++ compiler.

Designated initializers were introduced in ISO/IEC 9899:1999 (C99), but the code base is supposed to be compatible with an earlier version of the standard (C90). The InnoDB code based was switched from C to C++ in MySQL 5.6 and MariaDB 10.0.

C++ did not introduce syntax for designated initializers until ISO/IEC 14882:2020. MariaDB Server is still stuck with the 2011 or earlier version of the standard.

Therefore, this check as well as the macro STRUCT_FLD are best removed, to make the declarations easier to read and to slightly reduce the compile time by removing a useless compile-time check.


Generated at Thu Feb 08 09:45:21 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.