While rewriting GC code to use Atomic<T> we have seen compilation failures like this:
```
src/hotspot/share/gc/g1/g1ConcurrentMark.cpp:562:54: error: chosen constructor is explicit in copy-initialization
make: *** [product-bundles] Error 2
562 | ::new (&_region_mark_stats[i]) G1RegionMarkStats{};
| ^
src/hotspot/share/runtime/atomic.hpp:346:22: note: explicit constructor declared here
346 | explicit constexpr Atomic(T value = 0) : SupportsArithmetic<T>(value) {}
| ^
src/hotspot/share/gc/g1/g1RegionMarkStatsCache.hpp:44:18: note: in implicit initialization of field '_live_words' with omitted initializer
44 | Atomic<size_t> _live_words;
| ^
1 error generated.
```
This case be worked around by adding a constructor G1RegionMarkStats, and explicitly initializing the atomic variable.
It turns out that under certain conditions the `explicit` qualifier causes classes to not compile. I propose that we split the constructor into two, and only keep the `explicit` qualifier for the one-arg constructor.
```
src/hotspot/share/gc/g1/g1ConcurrentMark.cpp:562:54: error: chosen constructor is explicit in copy-initialization
make: *** [product-bundles] Error 2
562 | ::new (&_region_mark_stats[i]) G1RegionMarkStats{};
| ^
src/hotspot/share/runtime/atomic.hpp:346:22: note: explicit constructor declared here
346 | explicit constexpr Atomic(T value = 0) : SupportsArithmetic<T>(value) {}
| ^
src/hotspot/share/gc/g1/g1RegionMarkStatsCache.hpp:44:18: note: in implicit initialization of field '_live_words' with omitted initializer
44 | Atomic<size_t> _live_words;
| ^
1 error generated.
```
This case be worked around by adding a constructor G1RegionMarkStats, and explicitly initializing the atomic variable.
It turns out that under certain conditions the `explicit` qualifier causes classes to not compile. I propose that we split the constructor into two, and only keep the `explicit` qualifier for the one-arg constructor.
- links to
-
Review(master)
openjdk/jdk/29505