Project

General

Profile

Actions

Bug #2941

closed

need to protect __RESTRICT_KYWD from foolish compilers

Added by Rich Lowe over 9 years ago. Updated over 6 years ago.

Status:
Resolved
Priority:
Normal
Assignee:
Category:
lib - userland libraries
Start date:
2012-06-28
Due date:
% Done:

100%

Estimated time:
Difficulty:
Medium
Tags:
Gerrit CR:

Description

Certain foolhardy compilers have begun to assert that their C++ compiler complies with C99. It can't, that's a contradictory statement.

Unfortunately, we believe their spurious claims and allow the use of 'restrict' where it cannot reasonably be. We should protect ourselves from this.

Actions #1

Updated by Rich Lowe over 9 years ago

  • Status changed from In Progress to Resolved
  • % Done changed from 50 to 100

Resolved in r13746 commit:ad469755a3d5

Actions #2

Updated by Richard PALO over 6 years ago

I'd like to propose redoing this patch as follows:

diff --git a/usr/src/uts/common/sys/feature_tests.h b/usr/src/uts/common/sys/feature_tests.h
index 863b976..caad3e8 100644
--- a/usr/src/uts/common/sys/feature_tests.h
+++ b/usr/src/uts/common/sys/feature_tests.h
@@ -399,8 +399,12 @@ extern "C" {
  * compiler is used. This allows for the use of single prototype
  * declarations regardless of compiler version.
  */
-#if (defined(__STDC__) && defined(_STDC_C99)) && !defined(__cplusplus)
+#if (defined(__STDC__) && defined(_STDC_C99))
+#ifdef __cplusplus
+#define        _RESTRICT_KYWD  __restrict
+#else
 #define        _RESTRICT_KYWD  restrict
+#endif
 #else
 #define        _RESTRICT_KYWD
 #endif

As it is, gcc bootstraps fail define to define __restrict for g++ because
of it failing the fixincludes test.

My proposed https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61649 has more
or less fallen on deaf ears.

It is cleaner to fix the gate.

I've tested this with both gcc/g++ and studio cc/CC with both C99 mode and not
and all seems hunky dory.

I've bootstrapped gcc (now without my patch) and it swallows the good version just fine
as expected.

Question is, do I need to open a new bug?

Actions

Also available in: Atom PDF