You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copying struct/class with uninitialized members is consider as undefined behaviour. (Some References: [1], [2]).
And I found this kind of UB in some files.
struct Literal
Function createAsmNode<Literal>(_node) create a Literal object r, when this function return r;, struct Literal's implicit constructor is called, and r's uninitialized members kind is copied to retval.
Same as struct Literal, AssemblyItem's uninitialzed member m_instruction may be copied to retval while returning from function appendSubroutine, if m_type != Operation.
May be these uninitialized members will not be used later (or will be set before using them), it's better to eliminate these UBs by initializing these members with a specified value :)
The text was updated successfully, but these errors were encountered:
Copying struct/class with uninitialized members is consider as undefined behaviour. (Some References: [1], [2]).
And I found this kind of UB in some files.
struct Literal
Function
createAsmNode<Literal>(_node)
create aLiteral
objectr
, when this functionreturn r;
, structLiteral
's implicit constructor is called, andr
's uninitialized memberskind
is copied toretval
.solidity/libyul/AsmJsonImporter.cpp
Lines 167 to 169 in f369cdd
solidity/libyul/AsmJsonImporter.cpp
Lines 57 to 68 in f369cdd
kind
is not unsigned narrow character type orstd::byte
, andLiteralKind
object does not have default-initalization.solidity/libyul/AST.h
Line 69 in f369cdd
class AssemblyItem
move constructor
Same as struct
Literal
,AssemblyItem
's uninitialzed memberm_instruction
may be copied toretval
while returning from functionappendSubroutine
, ifm_type != Operation
.solidity/libevmasm/Assembly.h
Line 107 in f369cdd
solidity/libevmasm/Assembly.h
Line 74 in 26d5b3f
solidity/libevmasm/AssemblyItem.h
Lines 75 to 83 in f369cdd
m_instruction
is not unsigned narrow character type orstd::byte
, and will not be default initalized.solidity/libevmasm/AssemblyItem.h
Lines 217 to 229 in 26d5b3f
copy constructor
And also found some use of copy constructor before initializing
AssemblyItem
's memberm_instruction
.solidity/libsolidity/codegen/CompilerContext.cpp
Lines 593 to 599 in 26d5b3f
Summary
May be these uninitialized members will not be used later (or will be set before using them), it's better to eliminate these UBs by initializing these members with a specified value :)
The text was updated successfully, but these errors were encountered: