Bug 234504 - [Win] MSVC reports "DownloadBundleWin.cpp(87): error C2362: initialization of 'magic' is skipped by 'goto exit'" with /std:c++20
Summary: [Win] MSVC reports "DownloadBundleWin.cpp(87): error C2362: initialization of...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Platform (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Fujii Hironori
URL:
Keywords: InRadar
Depends on:
Blocks: 233448
  Show dependency treegraph
 
Reported: 2021-12-19 22:22 PST by Fujii Hironori
Modified: 2021-12-24 13:41 PST (History)
5 users (show)

See Also:


Attachments
Patch (6.98 KB, patch)
2021-12-19 22:25 PST, Fujii Hironori
no flags Details | Formatted Diff | Diff
Patch (7.02 KB, patch)
2021-12-20 12:50 PST, Fujii Hironori
no flags Details | Formatted Diff | Diff
Patch (7.16 KB, patch)
2021-12-20 12:57 PST, Fujii Hironori
no flags Details | Formatted Diff | Diff
Patch (2.49 KB, patch)
2021-12-21 16:57 PST, Fujii Hironori
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Fujii Hironori 2021-12-19 22:22:22 PST
[Win] MSVC reports "DownloadBundleWin.cpp(87): error C2362: initialization of 'magic' is skipped by 'goto exit'" with /std:c++20

> Source\WebCore\platform\network\win\DownloadBundleWin.cpp(87): error C2362: initialization of 'magic' is skipped by 'goto exit'
> Source\WebCore\platform\network\win\DownloadBundleWin.cpp(80): note: see declaration of 'magic'
> Source\WebCore\platform\network\win\DownloadBundleWin.cpp(87): note: see declaration of 'exit'
> Source\WebCore\platform\network\win\DownloadBundleWin.cpp(173): error C2362: initialization of 'footerStartPosition' is skipped by 'goto exit'
> Source\WebCore\platform\network\win\DownloadBundleWin.cpp(150): note: see declaration of 'footerStartPosition'
> Source\WebCore\platform\network\win\DownloadBundleWin.cpp(173): note: see declaration of 'exit'
> Source\WebCore\platform\network\win\DownloadBundleWin.cpp(173): error C2362: initialization of 'footerLength' is skipped by 'goto exit'
> Source\WebCore\platform\network\win\DownloadBundleWin.cpp(143): note: see declaration of 'footerLength'
> Source\WebCore\platform\network\win\DownloadBundleWin.cpp(173): note: see declaration of 'exit'
> Source\WebCore\platform\network\win\DownloadBundleWin.cpp(173): error C2362: initialization of 'footerLengthPosition' is skipped by 'goto exit'
> Source\WebCore\platform\network\win\DownloadBundleWin.cpp(135): note: see declaration of 'footerLengthPosition'
> Source\WebCore\platform\network\win\DownloadBundleWin.cpp(173): note: see declaration of 'exit'
> Source\WebCore\platform\network\win\DownloadBundleWin.cpp(173): error C2362: initialization of 'footerMagicNumber' is skipped by 'goto exit'
> Source\WebCore\platform\network\win\DownloadBundleWin.cpp(122): note: see declaration of 'footerMagicNumber'
> Source\WebCore\platform\network\win\DownloadBundleWin.cpp(173): note: see declaration of 'exit'
> Source\WebCore\platform\network\win\DownloadBundleWin.cpp(173): error C2362: initialization of 'footerMagicNumberPosition' is skipped by 'goto exit'
> Source\WebCore\platform\network\win\DownloadBundleWin.cpp(115): note: see declaration of 'footerMagicNumberPosition'
> Source\WebCore\platform\network\win\DownloadBundleWin.cpp(173): note: see declaration of 'exit'
Comment 1 Fujii Hironori 2021-12-19 22:25:12 PST
Created attachment 447584 [details]
Patch
Comment 2 Fujii Hironori 2021-12-20 12:50:37 PST
Created attachment 447624 [details]
Patch
Comment 3 Fujii Hironori 2021-12-20 12:57:48 PST
Created attachment 447626 [details]
Patch
Comment 4 EWS 2021-12-20 23:20:54 PST
Committed r287299 (245451@main): <https://commits.webkit.org/245451@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 447626 [details].
Comment 5 Radar WebKit Bug Importer 2021-12-20 23:21:16 PST
<rdar://problem/86755997>
Comment 6 Darin Adler 2021-12-21 01:07:27 PST
Comment on attachment 447626 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=447626&action=review

> Source/WebCore/platform/network/win/DownloadBundleWin.cpp:47
> +};

There should not be a semicolon here.

> Source/WebCore/platform/network/win/DownloadBundleWin.cpp:72
> +    std::unique_ptr<FILE, decltype(&fileCloser)> bundle(bundlePtr, &fileCloser);

Should be able to just write std::unique_ptr with no template arguments and rely on the deduction guide to deduce the argument types.

> Source/WebCore/platform/network/win/DownloadBundleWin.cpp:107
> +    std::unique_ptr<FILE, decltype(&fileCloser)> bundle(bundlePtr, &fileCloser);

Ditto.
Comment 7 Fujii Hironori 2021-12-21 12:06:33 PST
reopened.
Comment 8 Fujii Hironori 2021-12-21 14:05:04 PST
Comment on attachment 447626 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=447626&action=review

>> Source/WebCore/platform/network/win/DownloadBundleWin.cpp:72
>> +    std::unique_ptr<FILE, decltype(&fileCloser)> bundle(bundlePtr, &fileCloser);
> 
> Should be able to just write std::unique_ptr with no template arguments and rely on the deduction guide to deduce the argument types.

std::unique_ptr doesn't have the deduction guide.

  c++ - Why does std::unique_ptr not permit type inference? - Stack Overflow
  https://stackoverflow.com/q/41162868

  c++ - Why can't unique_ptr's template arguments be deduced? - Stack Overflow
  https://stackoverflow.com/q/51109767

And, I want to specify a deleter in this case.
And, C++17 lambda type doesn't have the default constructor.
C++20 can compile the following code.
> std::unique_ptr<FILE, decltype(&fileCloser)> bundle(bundlePtr);
Comment 9 Darin Adler 2021-12-21 14:38:33 PST
(In reply to Fujii Hironori from comment #8)
> std::unique_ptr doesn't have the deduction guide.

I understand why it can’t have one without a deleter; too bad it can’t have one with a deleter. Glad you investigated.
Comment 10 Fujii Hironori 2021-12-21 16:57:03 PST
Created attachment 447765 [details]
Patch
Comment 11 EWS 2021-12-24 13:40:58 PST
Committed r287432 (245567@main): <https://commits.webkit.org/245567@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 447765 [details].