aboutsummaryrefslogtreecommitdiff
path: root/m4
diff options
context:
space:
mode:
authoreldritch horrors <pennae@lix.systems>2024-03-04 05:24:33 +0100
committereldritch horrors <pennae@lix.systems>2024-03-04 05:24:33 +0100
commit559a8c44c3b59c046f4bb0bf049583ff234a095e (patch)
tree89681485d3cbfee39becc739b460807cb6c36d26 /m4
parent7ff1dca1fad24d0e8dd83172397d952ef6cb4de5 (diff)
Merge pull request #6258 from obsidiansystems/gcc-bug-ergonomics
Remove bug-avoiding `StoreConfig *` casts for settings (cherry picked from commit e3febfcd532adb23ca05ac465a2b907d6f1a3529) Change-Id: Ifeae276582fdbc781a38581df9de3da67a7e7bf9
Diffstat (limited to 'm4')
-rw-r--r--m4/gcc_bug_80431.m464
1 files changed, 64 insertions, 0 deletions
diff --git a/m4/gcc_bug_80431.m4 b/m4/gcc_bug_80431.m4
new file mode 100644
index 000000000..e42f01956
--- /dev/null
+++ b/m4/gcc_bug_80431.m4
@@ -0,0 +1,64 @@
+# Ensure that this bug is not present in the C++ toolchain we are using.
+#
+# URL for bug: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80431
+#
+# The test program is from that issue, with only a slight modification
+# to set an exit status instead of printing strings.
+AC_DEFUN([ENSURE_NO_GCC_BUG_80431],
+[
+ AC_MSG_CHECKING([that GCC bug 80431 is fixed])
+ AC_LANG_PUSH(C++)
+ AC_RUN_IFELSE(
+ [AC_LANG_PROGRAM(
+ [[
+ #include <cstdio>
+
+ static bool a = true;
+ static bool b = true;
+
+ struct Options { };
+
+ struct Option
+ {
+ Option(Options * options)
+ {
+ a = false;
+ }
+
+ ~Option()
+ {
+ b = false;
+ }
+ };
+
+ struct MyOptions : Options { };
+
+ struct MyOptions2 : virtual MyOptions
+ {
+ Option foo{this};
+ };
+ ]],
+ [[
+ {
+ MyOptions2 opts;
+ }
+ return (a << 1) | b;
+ ]])],
+ [status_80431=0],
+ [status_80431=$?],
+ [
+ # Assume we're bug-free when cross-compiling
+ ])
+ AC_LANG_POP(C++)
+ AS_CASE([$status_80431],
+ [0],[
+ AC_MSG_RESULT(yes)
+ ],
+ [2],[
+ AC_MSG_RESULT(no)
+ AC_MSG_ERROR(Cannot build Nix with C++ compiler with this bug)
+ ],
+ [
+ AC_MSG_RESULT(unexpected result $status_80431: not expected failure with bug, ignoring)
+ ])
+])