WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
290825
[TestWTF] Work around compiler bug in TypeCastsCocoa.mm test
https://bugs.webkit.org/show_bug.cgi?id=290825
Summary
[TestWTF] Work around compiler bug in TypeCastsCocoa.mm test
David Kilzer (:ddkilzer)
Reported
2025-03-31 20:26:12 PDT
Work around compiler bug in TypeCastsCocoa.mm test from TestWTF. In TestWTF.TypeCastsCocoa.dynamic_objc_cast_RetainPtr (and TestWTF.TypeCastsCocoaARC.dynamic_objc_cast_RetainPtr), this declaration using `auto` causes the destructor for `object` to be called before `object.get()` when combined with the `WTFMove()` in the previous statement, resulting in `nullptr` being returned. This was originally worked around in
291650@main
for
Bug 283039
by removing the `WTFMove()` call in the previous line, but then this code isn't testing `dynamic_objc_cast<T>(RetainPtr<U>&&)` anymore. A better workaround is to replace `auto` with `RetainPtr<id>` so that we can add back the `WTFMove()` so the test calls the intended function. ``` TEST(TypeCastsCocoa, dynamic_objc_cast_RetainPtr) { [...] @autoreleasepool { auto object = adoptNS<id>([[NSString alloc] initWithFormat:@"%s", helloWorldCString]); // "Bad" auto [...] RetainPtr<NSArray> objectCastBad; uintptr_t objectPtr2; AUTORELEASEPOOL_FOR_ARC_DEBUG { objectCastBad = dynamic_objc_cast<NSArray>(WTFMove(object)); objectPtr2 = reinterpret_cast<uintptr_t>(object.get()); // RetainPtr<id>::~RetainPtr() is called before object.get() here. } EXPECT_EQ(objectPtr, objectPtr2); EXPECT_EQ(nil, objectCastBad.get()); EXPECT_EQ(1L, CFGetRetainCount((CFTypeRef)objectPtr2)); } [...] } ```
Attachments
Add attachment
proposed patch, testcase, etc.
Radar WebKit Bug Importer
Comment 1
2025-03-31 20:26:41 PDT
<
rdar://problem/148299583
>
David Kilzer (:ddkilzer)
Comment 2
2025-03-31 20:31:22 PDT
Pull request:
https://github.com/WebKit/WebKit/pull/43373
EWS
Comment 3
2025-04-01 07:21:39 PDT
Committed
293007@main
(89cb37b46594): <
https://commits.webkit.org/293007@main
> Reviewed commits have been landed. Closing PR #43373 and removing active labels.
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug