Skip to content

Commit 0d9b02a

Browse files
committed
[nfc] Fix -Wdangling-field warning
LLVM 20 produces a warning since the type ptr is initialized with a constructor argument that will go out of scope. Initializing it with the ownType class variable instead resolves the warning.
1 parent 005f50b commit 0d9b02a

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/workerd/api/basics.h

+4-3
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ class Event: public jsg::Object {
3333
};
3434

3535
inline explicit Event(kj::String ownType, Init init = Init(), bool trusted = true)
36-
: type(ownType),
37-
ownType(kj::mv(ownType)),
36+
: ownType(kj::mv(ownType)),
37+
type(this->ownType),
3838
init(init),
3939
trusted(trusted) {}
4040

@@ -195,8 +195,9 @@ class Event: public jsg::Object {
195195
}
196196

197197
private:
198-
kj::StringPtr type;
198+
// listing ownType first so type can be initialized with it in constructor
199199
kj::String ownType;
200+
kj::StringPtr type;
200201
Init init;
201202
bool trusted = true;
202203
bool stopped = false;

0 commit comments

Comments
 (0)