Bug #2941
closedneed to protect __RESTRICT_KYWD from foolish compilers
100%
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.
Updated by Rich Lowe almost 10 years ago
- Status changed from In Progress to Resolved
- % Done changed from 50 to 100
Resolved in r13746 commit:ad469755a3d5
Updated by Richard PALO about 7 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?