RFR: 8331352: error: template-id not allowed for constructor/destructor in C++20

Kim Barrett kbarrett at openjdk.org
Tue Apr 30 04:03:04 UTC 2024


On Tue, 30 Apr 2024 02:01:01 GMT, Jan Kratochvil <jkratochvil at openjdk.org> wrote:

> When compiling trunk (819f3d6fc70ff6fe54ac5f9033c17c3dd4326aa5 2024-04-29) by gcc-14.0.1-0.15.fc40.x86_64 there are many errors: 
> 
> In file included from src/hotspot/share/memory/allocation.hpp:30,
>                  from src/hotspot/share/ci/ciBaseObject.hpp:29,
>                  from src/hotspot/share/ci/ciMetadata.hpp:28,
>                  from src/hotspot/share/ci/ciType.hpp:28,
>                  from src/hotspot/share/ci/ciKlass.hpp:28,
>                  from src/hotspot/share/ci/ciArrayKlass.hpp:28,
>                  from src/hotspot/share/ci/ciArray.hpp:28,
>                  from src/hotspot/share/ci/compilerInterface.hpp:28,
>                  from src/hotspot/share/compiler/abstractCompiler.hpp:28,
>                  from src/hotspot/share/compiler/abstractCompiler.cpp:25:
> src/hotspot/share/utilities/linkedlist.hpp:85:15: error: template-id not allowed for constructor in C++20 [-Werror=template-id-cdtor]
>    85 |   NONCOPYABLE(LinkedList<E>);
>       |               ^~~~~~~~~~~~~
> src/hotspot/share/utilities/globalDefinitions.hpp:87:26: note: in definition of macro ‘NONCOPYABLE’
>    87 | #define NONCOPYABLE(C) C(C const&) = delete; C& operator=(C const&) = delete /* next token must be ; */
>       |                          ^
> src/hotspot/share/utilities/linkedlist.hpp:85:15: note: remove the ‘< >’
>    85 |   NONCOPYABLE(LinkedList<E>);
>       |               ^~~~~~~~~~~~~
> src/hotspot/share/utilities/globalDefinitions.hpp:87:26: note: in definition of macro ‘NONCOPYABLE’
>    87 | #define NONCOPYABLE(C) C(C const&) = delete; C& operator=(C const&) = delete /* next token must be ; */
>       |                          ^
> 
> In file included from src/hotspot/share/gc/z/zGranuleMap.inline.hpp:30,
>                  from src/hotspot/share/gc/z/zForwardingTable.inline.hpp:32,
>                  from src/hotspot/share/gc/z/zHeap.inline.hpp:30,
>                  from src/hotspot/share/gc/z/zGeneration.inline.hpp:30,
>                  from src/hotspot/share/gc/z/zBarrier.inline.hpp:30,
>                  from src/hotspot/share/gc/z/zBarrierSet.inline.hpp:31,
>                  from src/hotspot/share/gc/shared/barrierSetConfig.inline.hpp:44,
>                  from src/hotspot/share/oops/access.inline.hpp:31,
>                  from src/hotspot/share/memory/iterator.inline.hpp:32,
>                  from src/hotspot/share/oops/oop.inline.hpp:31,
>                  from src/hotspot/share/compiler/abstractDisassembler.cpp:32:
> src/hotspot/share/gc/z/zArray.inline.hpp:99:21: error: template-id not allowed f...

The C++20 change comes from DR 2237
https://cplusplus.github.io/CWG/issues/2237.html
That resolution says:
"Note that this resolution is a change for C++20, NOT a defect report against
C++17 and earlier versions."

So it seems like a gcc bug that this error is being issues when not using
C++20.  OTOH, the changes involved seem beneficial to me, similarly to those
for JDK-8328997.

Looks good.

-------------

Marked as reviewed by kbarrett (Reviewer).

PR Review: https://git.openjdk.org/jdk/pull/19009#pullrequestreview-2030156549


More information about the hotspot-dev mailing list