]> git.ipfire.org Git - thirdparty/make.git/commitdiff
* src/makeint.h (free_alloca): Check for builtin alloca
authorPaul Smith <psmith@gnu.org>
Wed, 2 Dec 2020 22:29:16 +0000 (17:29 -0500)
committerPaul Smith <psmith@gnu.org>
Wed, 2 Dec 2020 22:29:16 +0000 (17:29 -0500)
src/makeint.h

index c4cc4dfddbaf593e3698e773cdd9b727f83d2f5b..70ee2b6daaea0057decdec5ed4303ae94f4d29b4 100644 (file)
@@ -43,10 +43,18 @@ char *alloca ();
 
 /* Some versions of GCC (e.g., 10.x) set the warn_unused_result attribute on
    __builtin_alloca.  This causes alloca(0) to fail and is not easily worked
-   around so make a helper.
+   around so avoid it via the preprocessor.
    See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98055  */
 
-#define free_alloca() do{ void *__p = alloca (0); (void)__p; }while(0)
+#if defined (__has_builtin)
+# if __has_builtin (__builtin_alloca)
+#   define free_alloca()
+# else
+#  define free_alloca() alloca (0)
+# endif
+#else
+# define free_alloca() alloca (0)
+#endif
 
 /* Disable assert() unless we're a maintainer.
    Some asserts are compute-intensive.  */