Skip to content

Fix -Wundef warnings for MBEDTLS_GCC_VERSION in alignment.h#10717

Open
lhuang04 wants to merge 1 commit into
Mbed-TLS:mbedtls-3.6from
lhuang04:fix-wundef-alignment-3.6
Open

Fix -Wundef warnings for MBEDTLS_GCC_VERSION in alignment.h#10717
lhuang04 wants to merge 1 commit into
Mbed-TLS:mbedtls-3.6from
lhuang04:fix-wundef-alignment-3.6

Conversation

@lhuang04

@lhuang04 lhuang04 commented Apr 27, 2026

Copy link
Copy Markdown
Contributor

Description

MBEDTLS_GCC_VERSION is only defined for GCC in build_info.h (excluded for clang via !defined(__clang__)). Lines 284 and 287 of alignment.h used it in bare #if directives without a defined() guard. When compiling with clang and -Wundef, the undefined macro triggers warnings through the include chain common.hbuild_info.halignment.h.

Add defined(MBEDTLS_COMPILER_IS_GCC) guard to both lines.

Reproduce

clang -fsyntax-only -Wundef -Werror \
    -I include -I library \
    library/common.h

Testing

Build and SSL test suites pass.

A corresponding fix for the development branch has been submitted as Mbed-TLS/TF-PSA-Crypto#(add PR number).

PR checklist

  • changelog not required because: trivial warning fix, no behavior change
  • framework PR not required
  • TF-PSA-Crypto development PR provided Mbed-TLS/TF-PSA-Crypto#(add PR number)
  • TF-PSA-Crypto 1.1 PR not required because: can backport after merge
  • mbedtls development PR not required because: file is in tf-psa-crypto submodule on development
  • mbedtls 4.1 PR not required because: file is in tf-psa-crypto submodule
  • mbedtls 3.6 PR provided (this PR)
  • tests not required because: compile-time warning fix only, no runtime behavior change

MBEDTLS_GCC_VERSION is only defined when the compiler is GCC (not
clang or other compilers). Lines 284 and 287 used it in bare #if
directives without a defined() guard, triggering -Wundef warnings.

Add defined(MBEDTLS_COMPILER_IS_GCC) guard to both lines.

Signed-off-by: Lin Huang <lhuang04@meta.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