Opened 16 months ago
Closed 15 months ago
#67890 closed defect (fixed)
blink @1.0.0: error: address argument to atomic operation must be a pointer to non-const _Atomic type
Reported by: | ryandesign (Ryan Carsten Schmidt) | Owned by: | herbygillot (Herby Gillot) |
---|---|---|---|
Priority: | Normal | Milestone: | |
Component: | ports | Version: | 2.8.1 |
Keywords: | highsierra | Cc: | ryandesign (Ryan Carsten Schmidt) |
Port: | blink |
Description (last modified by ryandesign (Ryan Carsten Schmidt))
On High Sierra and earlier (actually {clang >= 700 < 1001}
as far as I know):
./blink/jit.h:270:10: error: address argument to atomic operation must be a pointer to non-const _Atomic type ('const _Atomic(bool) *' invalid) return atomic_load_explicit(&jit->disabled, memory_order_acquire); ^ ~~~~~~~~~~~~~~
See https://github.com/php/php-src/issues/8881 for some background. It seems that there was a mistake in the original version of the C11 standard (something that should have been const
was defined to be non-const
), which clang obeyed, and which was changed in later versions of the standard; this code appears to be written to the revised C11 standard.
To address that PHP issue, the const
-ness is casted away like this:
source:macports-ports/lang/php/files/patch-php82-atomic.diff@d600ab208416957d0ca5e38259bfdcc6cfb38ef3
A similar patch could be written for blink.
Change History (4)
comment:1 Changed 16 months ago by jmroot (Joshua Root)
comment:2 Changed 16 months ago by ryandesign (Ryan Carsten Schmidt)
Oh. Well you're right, and I misremembered that part. Per this discussion that I linked to in the PHP issue:
C11, in its infinite wisdom, decided to drop the const, and C17 will fix this with DR459
But it also says:
I suggest we allow passing const _Atomic(T)* in all versions of C. It seems silly to special-case C11’s semantics because they allow strictly less code to work.
And the reply was:
Your plan sounds fine to me. We generally apply DR resolutions retroactively.
So in clang 1001 and later, the code should work even in C11 mode. But in earlier clangs in C11 mode is doesn't.
So one solution remains to make the code C11 compatible by casting away the const
ness as I said. Another solution is to require a C17 compiler. The port does not currently specify a compiler requirement. The project's README says it only requires a C11 compiler. I filed a bug report with the developers and suggested these two solutions.
comment:3 Changed 15 months ago by ryandesign (Ryan Carsten Schmidt)
Cc: | ryandesign added |
---|---|
Description: | modified (diff) |
No response from the developers yet. I'll update the port to require a C17 compiler for now.
comment:4 Changed 15 months ago by ryandesign (Ryan Carsten Schmidt)
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
The "revised C11 standard" is C17.