Skip to content

Fix system_code default argument in error_from_exception#175

Open
BillyONeal wants to merge 1 commit into
ned14:developfrom
BillyONeal:fix-status-code-system-code
Open

Fix system_code default argument in error_from_exception#175
BillyONeal wants to merge 1 commit into
ned14:developfrom
BillyONeal:fix-status-code-system-code

Conversation

@BillyONeal
Copy link
Copy Markdown

This cast is necessary to build on Visual Studio 2026 18.6.0 / MSVC 19.51 when llfio[status-code] is turned on

C:\Dev\vcpkg2\buildtrees\llfio\src\20260506-b0cb791d93.clean\include\llfio\v2.0\status_code.hpp(401,79): error C2440: 'default argument': cannot convert from 'system_error2::errc' to 'system_error2::system_code'
                     SYSTEM_ERROR2_NAMESPACE::system_code not_matched = errc::resource_unavailable_try_again) noexcept
                                                                              ^
C:\Dev\vcpkg2\buildtrees\llfio\src\20260506-b0cb791d93.clean\include\llfio\v2.0\status_code.hpp(401,79): note: No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called

I'm not sure exactly why the implicit conversion isn't working on the default argument here :/

Use generic_code() wrapper to construct the default system_code argument,
fixing a compilation issue with newer status-code implementations.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@ned14
Copy link
Copy Markdown
Owner

ned14 commented May 21, 2026

Y'know, if it's only MSVC barfing here, and MSVC until just now was happy, chances are this is a regression in latest MSVC right?

BillyONeal added a commit to BillyONeal/vcpkg that referenced this pull request May 22, 2026
Filed ned14/llfio#175 as a potential fix with upstream.
@BillyONeal
Copy link
Copy Markdown
Author

I don't know enough about changes in the spec, changes to MSVC, whether this code was exposed to MSVC before at all, etc. I'm just trying to update vcpkg's build lab without breaking our ability to test this port. ( microsoft/vcpkg#51854 )

If you believe the change isn't incorrect but believe that it is a compiler regression, would you view rejecting it here but accepting the patch in vcpkg as a workaround for that compiler acceptable?

@BillyONeal
Copy link
Copy Markdown
Author

FWIW part of the reason I tried this is that it seems like it would be strange for errc::anything to be directly convertible to a system_code. Which constructor are you expecting to get selected?

@ned14
Copy link
Copy Markdown
Owner

ned14 commented May 22, 2026

The MSVC CI is at https://github.com/ned14/llfio/actions/runs/25467721710/job/74724624804. As you can see, vs2022 is happy. Status code has been working on MSVC since its very beginning eight years too.

FWIW part of the reason I tried this is that it seems like it would be strange for errc::anything to be directly convertible to a system_code. Which constructor are you expecting to get selected?

Not at all, status code was intended by WG21 to be a complete superset replacement for error_code. So errc (and note, that's a library local errc not std::errc) absolutely implicitly converts into a system code. It'll take the constructor enabled by the ADL customisation point make_status_code() for errc.

I don't know enough about changes in the spec, changes to MSVC, whether this code was exposed to MSVC before at all, etc. I'm just trying to update vcpkg's build lab without breaking our ability to test this port. ( microsoft/vcpkg#51854 )

If you believe the change isn't incorrect but believe that it is a compiler regression, would you view rejecting it here but accepting the patch in vcpkg as a workaround for that compiler acceptable?

I'd like to be conclusively convinced what's going on here first. I say this due to an abundance of caution: WG21 changed C++ 23 in a way which broke this existing mature codebase on a recent update to clang, see #172. So it's entirely possible that WG21 is at fault here, and MSVC isn't at fault here. I'd like to know which first.

Also, there were some recent changes to how the ADL customisation point there was looked up. See ned14/status-code@b337c22 for a workaround to fix AppleClang being broken for recursive ADL lookup, for example.

What I can tell you Billy is that everything works on VS2022 and probably as far back as VS2019. Can you confirm it's working for you for VS2022 first, if it is but VS2026 isn't that would be a useful data point.

It's nearly 3am for me here - advantage of long term unemployment is I can stay up late when I want now - but I am also going to bed now. Good to hear from you again though Billy.

@BillyONeal
Copy link
Copy Markdown
Author

BillyONeal commented May 22, 2026

What I can tell you Billy is that everything works on VS2022 and probably as far back as VS2019. Can you confirm it's working for you for VS2022 first, if it is but VS2026 isn't that would be a useful data point.

I believe it does work in 2022 based on https://dev.azure.com/vcpkg/public/_build/results?buildId=131921

Installing 1645/2746 llfio[core,run-tests,status-code]:x64-windows@2026-05-06...
llfio[core,run-tests,status-code]:x64-windows@2026-05-06 package ABI: e78a6e36fb31d98d653928aa617da6b46b60edcdd11ea0aff56904e5f19ae941
Building llfio[core,run-tests,status-code]:x64-windows@2026-05-06...
Trying to download ned14-llfio-20260506.tar.gz using asset cache https://vcpkgassetcachewus.blob.core.windows.net/cache/d565298a7709a34482977406a7290cf109d44a428eb96c1ab788ceb8529ee4aa5736a8db9f51b0aeedb90c54bea00615038d24d0b26336aa6959fc11b8835ff6?*** SECRET ***
Download successful! Asset cache hit, did not try authoritative source https://github.com/ned14/llfio/archive/20260506.tar.gz
-- Extracting source D:/downloads/ned14-llfio-20260506.tar.gz
-- Using source at D:/b/llfio/src/20260506-b0cb791d93.clean
Trying to download ned14-ntkernel-error-category-5e50ff9af36a029c8ead9e0a833aa78304e95f28.tar.gz using asset cache https://vcpkgassetcachewus.blob.core.windows.net/cache/a3b8bfba8b22c79913ced23358c4a5ec56d2f2f8ca8da3ebd2e7cfaa783363d92d9de1b49766756c7b008114eee31c1509195232adcc364446eae724489be930?*** SECRET ***
Download successful! Asset cache hit, did not try authoritative source https://github.com/ned14/ntkernel-error-category/archive/5e50ff9af36a029c8ead9e0a833aa78304e95f28.tar.gz
-- Extracting source D:/downloads/ned14-ntkernel-error-category-5e50ff9af36a029c8ead9e0a833aa78304e95f28.tar.gz
-- Using source at D:/b/llfio/src/8304e95f28-00db124661.clean
Trying to download ned14-wg14_signals-36d3cdb66993078c8fecba93e2a5f2c549572d64.tar.gz using asset cache https://vcpkgassetcachewus.blob.core.windows.net/cache/096d8a539fc09635ca4ea11907244eef06d856719dd5fb4a1f07264c1b1896e6bfe6754af164435adbb57462c03779b90fdb12e284c9855a1d22274d53345fee?*** SECRET ***
Download successful! Asset cache hit, did not try authoritative source https://github.com/ned14/wg14_signals/archive/36d3cdb66993078c8fecba93e2a5f2c549572d64.tar.gz
-- Extracting source D:/downloads/ned14-wg14_signals-36d3cdb66993078c8fecba93e2a5f2c549572d64.tar.gz
-- Using source at D:/b/llfio/src/c549572d64-434848070e.clean
-- Configuring x64-windows
-- Building x64-windows-dbg
-- Building x64-windows-rel
-- Building x64-windows-dbg
-- Building x64-windows-rel
-- Installing: D:/p/llfio_x64-windows/share/llfio/usage
-- Installing: D:/p/llfio_x64-windows/share/llfio/copyright
-- Performing post-build validation
Starting submission of llfio[core,run-tests,status-code]:x64-windows@2026-05-06 to 1 binary cache(s) in the background
Elapsed time to handle llfio:x64-windows: 2.7 min

It's nearly 3am for me here - advantage of long term unemployment is I can stay up late when I want now - but I am also going to bed now. Good to hear from you again though Billy.

Ooof I'm sorry to hear about that :( . Don't feel like you have to stay up late on my account! Good to hear from you again too.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants