Gavin Smith wrote:
On Fri, Apr 14, 2017 at 07:00:06PM -0700, Paul Eggert wrote:
On 04/14/2017 02:27 PM, Gavin Smith wrote:
/opt/solarisstudio12.3/bin/c99 -Xc -D_XPG6 -DHAVE_CONFIG_H -I. -I../..
-D_REENTRANT  -I/opt/csw/include -c -o regex.o regex.c
"regex_internal.h", line 105: warning: macro redefined: gettext

That's odd. Where was the gettext macro originally defined?

/opt/csw/include/libintl.h, line 132: #define gettext libintl_gettext

Sorry, I don't understand how this could be. regex_internal.h's "#define gettext(msgid) msgid" line is in the else-part of the #if that #includes libintl.h in its then-part, so how can libintl.h's #define for gettext be active when regex_internal's #define is processed?

I only have access to 12.4 on the system I am using, but that appears to
compile the test file I posted without error. Solaris Studio 12.2 gives
the same error as 12.3.

Thanks, I installed the attached (comment-only) patches to try to explain this better. The first just fixes a typo. The 2nd has a messed-up commit message that I didn't discover until after pushing - oh well, the ChangeLog file is right.
From f05e6ea8927664df6fa55d2f11a60f1b5ca4e399 Mon Sep 17 00:00:00 2001
From: Paul Eggert <egg...@cs.ucla.edu>
Date: Fri, 14 Apr 2017 19:03:20 -0700
Subject: [PATCH 1/2] intprops: fix comment typo

---
 lib/intprops.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/intprops.h b/lib/intprops.h
index ca8740d..e2ed277 100644
--- a/lib/intprops.h
+++ b/lib/intprops.h
@@ -461,8 +461,8 @@ verify (TYPE_WIDTH (unsigned int) == UINT_WIDTH);
    E.g., GCC converts to signed integers in the usual way; see:
    https://gcc.gnu.org/onlinedocs/gcc/Integers-implementation.html
    All other known C compilers are similar to GCC in this respect.
-   Furthermore, Oracle Studio Studio 12.3 x86 has a bug when
-   implementing the standard way; see:
+   Furthermore, Oracle Studio 12.3 x86 has a bug when implementing the
+   standard way; see:
    http://lists.gnu.org/archive/html/bug-gnulib/2017-04/msg00049.html
 
    So, implement this operation in the usual way rather than in
-- 
2.7.4

From 5ea3e3a16120bbac604fa9fcfdaa94126c9ead53 Mon Sep 17 00:00:00 2001
From: Paul Eggert <egg...@penguin.cs.ucla.edu>
Date: Sat, 15 Apr 2017 14:27:11 -0700
Subject: [PATCH 2/2] intprops: improve comments

* lib/intprops.h: Improve and shorten commentary.
For the record, if we ever run into a pedantic compiler that
behaves differently from GCC when converting an out-of-range value
to a signed integer, we can work around the problem with something
like the following code, where UCT is the signed counterpart of T
(UCT is sometimes narrower than UT) and all callers are changed
accordingly:
   ((t) ((ut) (a) op (ut) (b)))
   (TYPE_MINIMUM (t) <= (uct) ((ut) (a) op (ut) (b)) \
    ? ((t) (uct) (((ut) (a) op (ut) (b)) - TYPE_MINIMUM (t)) \
       + TYPE_MINIMUM (t)) \
    : (t) (uct) ((ut) (a) op (ut) (b)))
---
 ChangeLog      | 21 +++++++++++++++++++++
 lib/intprops.h | 33 +++++++++++++--------------------
 2 files changed, 34 insertions(+), 20 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 5ed1517..b19910b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,24 @@
+2017-04-15  Paul Eggert  <egg...@penguin.cs.ucla.edu>
+
+	intprops: improve comments
+	* lib/intprops.h: Improve and shorten commentary.
+	For the record, if we ever run into a pedantic compiler that
+	behaves differently from GCC when converting an out-of-range value
+	to a signed integer, we can work around the problem with something
+	like the following code, where UCT is the signed counterpart of T
+	(UCT is sometimes narrower than UT) and all callers are changed
+	accordingly:
+	#if __SUNPRO_C <= 0x5120
+	# define _GL_INT_OP_WRAPV_VIA_UNSIGNED(a, b, op, uct, ut, t) \
+	   ((t) ((ut) (a) op (ut) (b)))
+	#else
+	# define _GL_INT_OP_WRAPV_VIA_UNSIGNED(a, b, op, uct, ut, t) \
+	   (TYPE_MINIMUM (t) <= (uct) ((ut) (a) op (ut) (b)) \
+	    ? ((t) (uct) (((ut) (a) op (ut) (b)) - TYPE_MINIMUM (t)) \
+	       + TYPE_MINIMUM (t)) \
+	    : (t) (uct) ((ut) (a) op (ut) (b)))
+	#endif
+
 2017-04-14  Paul Eggert  <egg...@penguin.cs.ucla.edu>
 
 	intprops: try to avoid tickling similar bugs
diff --git a/lib/intprops.h b/lib/intprops.h
index e2ed277..c31a455 100644
--- a/lib/intprops.h
+++ b/lib/intprops.h
@@ -444,29 +444,22 @@ verify (TYPE_WIDTH (unsigned int) == UINT_WIDTH);
    ? (*(r) = _GL_INT_OP_WRAPV_VIA_UNSIGNED (a, b, op, ut, t), 1) \
    : (*(r) = _GL_INT_OP_WRAPV_VIA_UNSIGNED (a, b, op, ut, t), 0))
 
-/* Return A <op> B, where the operation is given by OP.  Return the
-   low-order bits of the mathematically-correct answer.  Use the
-   unsigned type UT for calculation to avoid undefined behavior on
-   signed integer overflow.  Assume that conversion to the result type
-   T yields the low-order bits in the usual way.  UT is at least as
-   wide as T and is no narrower than unsigned int, T is two's
-   complement, and there is no padding or trap representations.
+/* Return the low-order bits of A <op> B, where the operation is given
+   by OP.  Use the unsigned type UT for calculation to avoid undefined
+   behavior on signed integer overflow, and convert the result to type T.
+   UT is at least as wide as T and is no narrower than unsigned int,
+   T is two's complement, and there is no padding or trap representations.
+   Assume that converting UT to T yields the low-order bits, as is
+   done in all known two's-complement C compilers.  E.g., see:
+   https://gcc.gnu.org/onlinedocs/gcc/Integers-implementation.html
 
    According to the C standard, converting UT to T yields an
-   implementation-defined result or signal for values outside T's range.
-   So, the standard way to convert UT to T is to subtract TMIN from
-   greater-than-TMAX values before converting them to T, and to add
-   TMIN afterwards, where TMIN and TMAX are T's extrema.
-   However, in practice there is no need to subtract and add TMIN.
-   E.g., GCC converts to signed integers in the usual way; see:
-   https://gcc.gnu.org/onlinedocs/gcc/Integers-implementation.html
-   All other known C compilers are similar to GCC in this respect.
-   Furthermore, Oracle Studio 12.3 x86 has a bug when implementing the
-   standard way; see:
+   implementation-defined result or signal for values outside T's
+   range.  However, code that works around this theoretical problem
+   runs afoul of a compiler bug in Oracle Studio 12.3 x86.  See:
    http://lists.gnu.org/archive/html/bug-gnulib/2017-04/msg00049.html
-
-   So, implement this operation in the usual way rather than in
-   the standard way.  */
+   As the compiler bug is real, don't try to work around the
+   theoretical problem.  */
 
 #define _GL_INT_OP_WRAPV_VIA_UNSIGNED(a, b, op, ut, t) \
   ((t) ((ut) (a) op (ut) (b)))
-- 
2.7.4

Reply via email to