Skip to content

Mutually forward-declared types used in templates cause incomplete-type errors in Kendra #3694

@BwL1289

Description

@BwL1289

Describe the bug

When building the AWS SDK w/ C++23, compilation fails due to incomplete types being used in template expressions in the Kendra client that result in error: arithmetic on a pointer to an incomplete type

Specifically, the following two model classes reference each other only via forward declarations:

  • DocumentAttributeValueCountPair
  • FacetResult

The current workaround is to downgrade to c++17.

Related:

Regression Issue

  • Select this option if this issue appears to be a regression.

Expected Behavior

Compilation to succeed

Current Behavior

Compilation crashes with

/opt/llvm_toolchain/bin/../include/c++/v1/__vector/vector.h:1103:5: error: arithmetic on a pointer to an incomplete type 'Aws::kendra::Model::DocumentAttributeValueCountPair'
 1103 |     ++__end;
      |     ^ ~~~~~
/opt/llvm_toolchain/bin/../include/c++/v1/__vector/vector.h:446:90: note: in instantiation of function template specialization 'std::vector<Aws::kendra::Model::DocumentAttributeValueCountPair>::emplace_back<Aws::kendra::Model::DocumentAttributeValueCountPair>' requested here
  446 |   _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void push_back(value_type&& __x) { emplace_back(std::move(__x)); }
      |                                                                                          ^
/tmp/eugo/aws-sdk-cpp-1.11.453/generated/src/aws-cpp-sdk-kendra/include/aws/kendra/model/FacetResult.h:85:192: note: in instantiation of member function 'std::vector<Aws::kendra::Model::DocumentAttributeValueCountPair>::push_back' requested here
   85 |     inline FacetResult& AddDocumentAttributeValueCountPairs(DocumentAttributeValueCountPair&& value) { m_documentAttributeValueCountPairsHasBeenSet = true; m_documentAttributeValueCountPairs.push_back(std::move(value)); return *this; }
      |                                                                                                                                                                                                ^
/tmp/eugo/aws-sdk-cpp-1.11.453/generated/src/aws-cpp-sdk-kendra/include/aws/kendra/model/FacetResult.h:28:9: note: forward declaration of 'Aws::kendra::Model::DocumentAttributeValueCountPair'
   28 |   class DocumentAttributeValueCountPair;
      |         ^
In file included from /tmp/eugo/aws-sdk-cpp-1.11.453/eugo_build/generated/src/aws-cpp-sdk-kendra/ub_KENDRA.cpp:2:
In file included from /tmp/eugo/aws-sdk-cpp-1.11.453/generated/src/aws-cpp-sdk-kendra/source/KendraEndpointProvider.cpp:6:
In file included from /tmp/eugo/aws-sdk-cpp-1.11.453/generated/src/aws-cpp-sdk-kendra/include/aws/kendra/KendraEndpointProvider.h:8:
In file included from /tmp/eugo/aws-sdk-cpp-1.11.453/src/aws-cpp-sdk-core/include/aws/core/client/GenericClientConfiguration.h:9:
In file included from /tmp/eugo/aws-sdk-cpp-1.11.453/src/aws-cpp-sdk-core/include/aws/core/client/ClientConfiguration.h:9:
In file included from /tmp/eugo/aws-sdk-cpp-1.11.453/src/aws-cpp-sdk-core/include/aws/core/http/Scheme.h:10:
In file included from /tmp/eugo/aws-sdk-cpp-1.11.453/src/aws-cpp-sdk-core/include/aws/core/utils/memory/stl/AWSString.h:12:
In file included from /opt/llvm_toolchain/bin/../include/c++/v1/functional:552:
In file included from /opt/llvm_toolchain/bin/../include/c++/v1/__functional/boyer_moore_searcher.h:25:
/opt/llvm_toolchain/bin/../include/c++/v1/__vector/vector.h:1109:18: error: arithmetic on a pointer to an incomplete type 'Aws::kendra::Model::DocumentAttributeValueCountPair'
 1109 |   return *(__end - 1);
      |            ~~~~~ ^
/tmp/eugo/aws-sdk-cpp-1.11.453/generated/src/aws-cpp-sdk-kendra/include/aws/kendra/model/FacetResult.h:28:9: note: forward declaration of 'Aws::kendra::Model::DocumentAttributeValueCountPair'
   28 |   class DocumentAttributeValueCountPair;
      |         ^
15 errors generated.
ninja: build stopped: subcommand failed.

Reproduction Steps

Build from sources with C++20 or C++23. For example:

cmake .. \
  -DCMAKE_COMPILE_WARNING_AS_ERROR=OFF \
  -DCMAKE_LINK_WARNING_AS_ERROR=OFF \
  -DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
  -DCMAKE_MESSAGE_LOG_LEVEL=debug \
  -DCMAKE_COLOR_DIAGNOSTICS=ON \
  -DCMAKE_BUILD_TYPE=Release \
  -DCMAKE_C_STANDARD='17' \
  -DCMAKE_C_EXTENSIONS=ON \
  -DCMAKE_CXX_STANDARD='23' \
  -DCMAKE_CXX_EXTENSIONS=ON \ 
  -DCPP_STANDARD="23" \
  -DCMAKE_INSTALL_PREFIX="/usr/local" \
  -DBUILD_SHARED_LIBS=ON \
  -DFORCE_SHARED_CRT=ON \
  -DIN_SOURCE_BUILD=OFF \
  -DLEGACY_BUILD=ON \
  -DENABLE_UNITY_BUILD=ON \
  -DMINIMIZE_SIZE=OFF \
  -DSIMPLE_INSTALL=ON \
  -DREGENERATE_CLIENTS=OFF \
  -DREGENERATE_DEFAULTS=OFF \
  -DUSE_CRT_HTTP_CLIENT=OFF \
  -DENABLE_RTTI=ON

Possible Solution

No response

Additional Information/Context

No response

AWS CPP SDK version used

1.11.453

Compiler and Version used

Clang 20.0.0git

Operating System and version

Amz Linux 2023 (aarch64 Fedora based)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugThis issue is a bug.needs-triageThis issue or PR still needs to be triaged.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions