Skip to content

Conversation

@eramongodb
Copy link
Contributor

Clang 21 was released on 2025-08-26. It seems to have made improvements to its -Wuninitialized diagnostics, which now flag this piece of code:

error: variable 'val' is uninitialized when passed as a const pointer argument here [-Werror,-Wuninitialized-const-pointer]
   43 |    BSON_ASSERT(BCON_EXTRACT(bcon, "foo", BCONE_DECIMAL128(val)));
      |                                                           ^~~

where the BCONE_DECIMAL128(val) expands into:

bcon_extract((bcon),
             "foo",
             bson_bcone_magic(),
             BCON_TYPE_DECIMAL128,
             bcon_ensure_const_decimal128_ptr(&((val))),
//                                            ^~~~~~~~ 
             (void *)NULL)

and bcon_ensure_const_decimal128_ptr has parameter type const bson_decimal128_t *:

The diagnostic reasonably assumes the T in a T const* parameter will be read-from. This is not the case here: bcon_ensure_* is just performing an existence check. However, this is nevertheless triggering our unconditional -Werror=uninitialized flag:

# Definite use of uninitialized value
gnu-like:-Werror=uninitialized msvc:/we4700

@eramongodb eramongodb requested a review from kevinAlbs October 22, 2025 18:46
@eramongodb eramongodb self-assigned this Oct 22, 2025
@eramongodb eramongodb requested a review from a team as a code owner October 22, 2025 18:46
Copy link
Collaborator

@kevinAlbs kevinAlbs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you. LGTM

@eramongodb eramongodb merged commit 42cea44 into mongodb:master Oct 22, 2025
15 of 17 checks passed
@eramongodb eramongodb deleted the cdriver-clang-21 branch October 22, 2025 19:10
eramongodb added a commit to eramongodb/mongo-c-driver that referenced this pull request Oct 22, 2025
eramongodb added a commit that referenced this pull request Oct 22, 2025
* Fix unused test_framework_skip_if_not_single_version_5 warning

* CDRIVER-5990 skip auth tests on zSeries (#1996)

zSeries hosts are unable to connect to test server. See: DEVPROD-16954

* CDRIVER-6071 replace build-and-test-with-toolchain with openssl-compat (#2082)

* Remove build-and-test-with-toolchain task
* Add openssl-downloader.sh
* CDRIVER-5995: unskip relevant auth tests
* Fix and update run-auth-tests.sh
* Fix and update run-aws-tests.sh
* Fix and update run-ocsp-test.sh
* Migrate OpenSSL compatibility checks into openssl-compat matrix
* Disable failing OCSP darwinssl tasks
* Add verification of shared vs. static linkage of OpenSSL
* Remove obsolete BYPASS_FIND_CMAKE branches
* Support forwarding extra CMake flags to compile_libmongocrypt
* Add reference to CDRIVER-3759

* CDRIVER-6075 fix and update EVG task coverage on MacOS distros (#2088)

* CDRIVER-6075 fix and update EVG task coverage on MacOS distros
* CDRIVER-6079 skip /scram/cache_invalidation on macos-14-arm64

* CDRIVER-5987 remove serverless testing (#2116)

* CDRIVER-6065 remove atlas data lake testing (#2117)

* DRIVERS-3279 check for new "too-large" error code (#2106)

* Address -Wuninitialized-const-pointer with Clang 21 (#2155)

---------

Co-authored-by: Kevin Albertson <kevin.albertson@mongodb.com>
Co-authored-by: Connor MacDonald <connor.macdonald@mongodb.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants