Skip to content

Conversation

@shafik
Copy link
Collaborator

@shafik shafik commented Aug 14, 2025

Static analysis flagged that the non-static member Semantics was not initialized by the default default constructor. Fix is to initialize it using in class member initialization.

…ting

Static analysis flagged that the non-static member Semantics was not initialized
by the default default constructor. Fix is to initialize it using in class
member initialization.
@llvmbot llvmbot added clang Clang issues not falling into any other category clang:frontend Language frontend issues, e.g. anything involving "Sema" clang:bytecode Issues for the clang bytecode constexpr interpreter labels Aug 14, 2025
@llvmbot
Copy link
Member

llvmbot commented Aug 14, 2025

@llvm/pr-subscribers-clang

Author: Shafik Yaghmour (shafik)

Changes

Static analysis flagged that the non-static member Semantics was not initialized by the default default constructor. Fix is to initialize it using in class member initialization.


Full diff: https://github.com/llvm/llvm-project/pull/153671.diff

1 Files Affected:

  • (modified) clang/lib/AST/ByteCode/Floating.h (+1-1)
diff --git a/clang/lib/AST/ByteCode/Floating.h b/clang/lib/AST/ByteCode/Floating.h
index 659892e720abf..9561aee434d91 100644
--- a/clang/lib/AST/ByteCode/Floating.h
+++ b/clang/lib/AST/ByteCode/Floating.h
@@ -38,7 +38,7 @@ class Floating final {
     uint64_t Val = 0;
     uint64_t *Memory;
   };
-  llvm::APFloatBase::Semantics Semantics;
+  llvm::APFloatBase::Semantics Semantics{};
 
   APFloat getValue() const {
     unsigned BitWidth = bitWidth();

@tbaederr
Copy link
Contributor

This was on purpose, see #144246 (comment)

@AaronBallman
Copy link
Collaborator

Static analysis flagged that the non-static member Semantics was not initialized by the default default constructor. Fix is to initialize it using in class member initialization.

Yeah, this might be one better to mark as Intentional in the static analysis tool; there really isn't a sensible default value to begin with, so getting sanitizer coverage seems like a better approach IMO.

@shafik
Copy link
Collaborator Author

shafik commented Aug 15, 2025

Static analysis flagged that the non-static member Semantics was not initialized by the default default constructor. Fix is to initialize it using in class member initialization.

Yeah, this might be one better to mark as Intentional in the static analysis tool; there really isn't a sensible default value to begin with, so getting sanitizer coverage seems like a better approach IMO.

Yes but we have a default constructor, then maybe we should not have one then? It looks like it is only used for TYPE_SWITCH and in that case if we need it then maybe there should be some explanatory comments detailing why this is so folks finding this in the future can understand the use.

@AaronBallman
Copy link
Collaborator

Static analysis flagged that the non-static member Semantics was not initialized by the default default constructor. Fix is to initialize it using in class member initialization.

Yeah, this might be one better to mark as Intentional in the static analysis tool; there really isn't a sensible default value to begin with, so getting sanitizer coverage seems like a better approach IMO.

Yes but we have a default constructor, then maybe we should not have one then? It looks like it is only used for TYPE_SWITCH and in that case if we need it then maybe there should be some explanatory comments detailing why this is so folks finding this in the future can understand the use.

Explanatory comments make sense to me, I think it's fine to add those

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

clang:bytecode Issues for the clang bytecode constexpr interpreter clang:frontend Language frontend issues, e.g. anything involving "Sema" clang Clang issues not falling into any other category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants