Subject: bug#22087: closed (Re: bug#22087: Problem with stdbuf configure test for 8.24 on Solaris with Studio C compiler.)

From: [email-masked] (GNU bug Tracking System)
Date: Thu, 03 Dec 2015 21:58:03 +0000

Your bug report

#22087: Problem with stdbuf configure test for 8.24 on Solaris with Studio C compiler.

which was filed against the coreutils package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
22087: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=22087
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#22087: Problem with stdbuf configure test for 8.24 on Solaris with Studio C compiler.
From: Paul Eggert <[email-masked]>
To: Rich Burridge <[email-masked]>, Pádraig Brady<[email-masked]>, [email-masked]
Date: Thu, 3 Dec 2015 13:57:45 -0800
List-Id: <debbugs-submit.debbugs.gnu.org>

On 12/03/2015 01:08 PM, Rich Burridge wrote:
> Yup. That works nicely too. 

Thanks, I noticed a similar problem in three other places (which I guess 
don't affect your platform) and so installed the attached more-general 
patch.
>From c536d89fc497f90464de61c5b4207d103dfbad08 Mon Sep 17 00:00:00 2001
From: Paul Eggert <[email-masked]>
Date: Thu, 3 Dec 2015 13:55:44 -0800
Subject: [PATCH] build: port to Studio C on Solaris 12

Reported by Rich Burridge in: http://bugs.gnu.org/22087
* configure.ac (HAVE_UT_HOST, HAVE_C_LINE, stdbuf):
Pacify picky compilers that complain about unreachable statements.
---
 configure.ac | 21 ++++++++++++++-------
 1 file changed, 14 insertions(+), 7 deletions(-)

diff --git a/configure.ac b/configure.ac
index 66c8cbe..a5c4e41 100644
--- a/configure.ac
+++ b/configure.ac
@@ -354,7 +354,9 @@ coreutils_DUMMY_1
 AC_MSG_CHECKING([ut_host in struct utmp])
 AC_CACHE_VAL([su_cv_func_ut_host_in_utmp],
 [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
-#include <utmp.h>]], [[struct utmp ut; return !sizeof ut.ut_host;]])],
+                                   #include <utmp.h>
+                                   struct utmp ut;
+                                   int s = sizeof ut.ut_host;]])],
   [su_cv_func_ut_host_in_utmp=yes],
   [su_cv_func_ut_host_in_utmp=no])])
 AC_MSG_RESULT([$su_cv_func_ut_host_in_utmp])
@@ -367,7 +369,9 @@ if test -z "$have_ut_host"; then
   AC_MSG_CHECKING([ut_host in struct utmpx])
   AC_CACHE_VAL([su_cv_func_ut_host_in_utmpx],
   [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
-#include <utmpx.h>]], [[struct utmpx ut; return !sizeof ut.ut_host;]])],
+                                     #include <utmpx.h>
+                                     struct utmpx ut;
+                                     int s = sizeof ut.ut_host;]])],
     [su_cv_func_ut_host_in_utmpx=yes],
     [su_cv_func_ut_host_in_utmpx=no])])
   AC_MSG_RESULT([$su_cv_func_ut_host_in_utmpx])
@@ -404,10 +408,12 @@ yes
   AC_MSG_CHECKING([c_line in struct termios])
   AC_CACHE_VAL([su_cv_sys_c_line_in_termios],
   [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#if TERMIOS_NEEDS_XOPEN_SOURCE
-#define _XOPEN_SOURCE
-#endif
-#include <sys/types.h>
-#include <termios.h>]], [[struct termios t; return !sizeof t.c_line;]])],
+                                      #define _XOPEN_SOURCE
+                                     #endif
+                                     #include <sys/types.h>
+                                     #include <termios.h>
+                                     struct termios t;
+                                     int s = sizeof t.c_line;]])],
     [su_cv_sys_c_line_in_termios=yes],
     [su_cv_sys_c_line_in_termios=no])])
   AC_MSG_RESULT([$su_cv_sys_c_line_in_termios])
@@ -475,7 +481,8 @@ AC_LINK_IFELSE(
     {
       stdbuf = 1;
     }]],[[
-    return !(stdbuf == 1);]])
+    if (stdbuf != 1)
+      return 1;]])
   ],
   [stdbuf_supported=yes])
 AC_MSG_RESULT([$stdbuf_supported])
-- 
2.1.0

Subject: Problem with stdbuf configure test for 8.24 on Solaris with Studio C compiler.
From: Rich Burridge <[email-masked]>
To: [email-masked]
Date: Thu, 3 Dec 2015 10:58:26 -0800
List-Id: <debbugs-submit.debbugs.gnu.org>

Hi,

I'm finally getting around to integrating coreutils version 8.24
into Solaris 12 (and being built with the Studio C compiler rather
than gcc) and noticed that the test for whether we had stdbuf was
failing.

I've fixed it with the following patch. Looks like gcc just doesn't
trip over this, but hopefully the suggested change "just works" for
both compilers.

Thanks.

$ cat configure.ac.patch
The configure test for "whether this is system supports stdbuf" was
failing because the warning:

"conftest.c", line 731: warning: statement not reached

was being turned into an error with the Studio C compiler (ignored
with the GNU C compiler).

We want to adjust the -errwarn option so that it ignores
E_STATEMENT_NOT_REACHED errors.

--- configure.ac.orig   2015-12-03 09:46:42.381111611 -0800
+++ configure.ac        2015-12-03 10:27:48.938546667 -0800
@@ -459,7 +459,7 @@
  ac_save_LDFLAGS=$LDFLAGS
  # Detect warnings about ignored "constructor" attributes.
  gl_WARN_ADD([-Werror], [CFLAGS])
-gl_WARN_ADD([-errwarn], [CFLAGS])
+gl_WARN_ADD([-errwarn=no%E_STATEMENT_NOT_REACHED], [CFLAGS])
  # Put this message here, after gl_WARN_ADD's chatter.
  AC_MSG_CHECKING([whether this system supports stdbuf])
  CFLAGS="-fPIC $CFLAGS"