Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[C++][MSVC] Arrow failed to build with MSVC under /std:c++latest mode due to error C2280: 'std::basic_string<char,std::char_traits<char>,std::allocator<char>>::basic_string(std::nullptr_t)': attempting to reference a deleted function #35501

Closed
Zhaojun-Liu opened this issue May 9, 2023 · 5 comments · Fixed by #35683

Comments

@Zhaojun-Liu
Copy link
Contributor

Zhaojun-Liu commented May 9, 2023

Describe the bug, including details regarding any error messages, version, and platform.

Hi all,
Recently, we updated the commit of Arrow, and it failed to build with MSVC due to below error on Windows with option /std:c++latest:
error C2280: 'std::basic_string<char,std::char_traits<char>,std::allocator<char>>::basic_string(std::nullptr_t)': attempting to reference a deleted function
Could you please help look this issue? Thanks.

Repro steps:

  1. git clone https://github.com/apache/arrow F:\gitP\apache\arrow
  2. git -C "F:\gitP\apache\arrow" submodule sync
  3. git -C "F:\gitP\apache\arrow" submodule update --init --recursive
  4. mkdir F:\gitP\apache\arrow\cpp\build_amd64 and cd F:\gitP\apache\arrow\cpp\build_amd64
  5. set _CL_= /std:c++latest
  6. cmake -G "Visual Studio 17 2022" -A x64 -DCMAKE_SYSTEM_VERSION=10.0.22621.0 -DCMAKE_BUILD_TYPE=Release -DARROW_BUILD_TESTS=ON -DBOOST_ROOT=F:\tools\boost_1_77_0\x64 ..
  7. msbuild /maxcpucount:1 /p:Platform=x64 /p:Configuration=Release arrow.sln /t:Rebuild

The commit we use: f9324b7

Expected result:
Build successfully.

Actual result:
F:\gitP\apache\arrow\cpp\src\arrow/compute/function_internal.h(289,3): error C2280: 'std::basic_string<char,std::char_traits<char>,std::allocator<char>>::basic_string(std::nullptr_t)': attempting to reference a deleted function [F:\gitP\apache\arrow\cpp\build_amd64\src\arrow\arrow_static.vcxproj]

Detailed log:
build.log

Component(s)

C++

@kou
Copy link
Member

kou commented May 9, 2023

It seems that std::basic_string::basic_string(std::nullptr_t) is deleted since C++23.
It will be related to this.

@westonpace
Copy link
Member

@Zhaojun-Liu are you interested in contributing a PR?

@Zhaojun-Liu
Copy link
Contributor Author

@Zhaojun-Liu are you interested in contributing a PR?

In our test, I just try to change nullptr to be "" at line https://github.com/apache/arrow/blob/main/cpp/src/arrow/compute/function_internal.h#L289, and it will build ok, but I'm not sure if this change will have other effects.

@kou
Copy link
Member

kou commented May 19, 2023

Using std::basic_string::basic_string("") instead of std::basic_string::basic_string(std::nullptr_t) is a right approach.
Could you open a pull request with the approach?

@Zhaojun-Liu
Copy link
Contributor Author

Using std::basic_string::basic_string("") instead of std::basic_string::basic_string(std::nullptr_t) is a right approach. Could you open a pull request with the approach?

Ok, I have submitted the pull request.

@kou kou added this to the 13.0.0 milestone May 22, 2023
kou pushed a commit that referenced this issue May 22, 2023
### Rationale for this change
Arrow failed to build with error C2280 under MSVC cpplatest mode, because std::basic_string::basic_string(std::nullptr_t) is deleted since C++23. So, using `std::basic_string::basic_string("")` to replace `std::basic_string::basic_string(std::nullptr_t)` to fix this issue. 

Related issue: #35501 

### What changes are included in this PR?

### Are these changes tested?

### Are there any user-facing changes?

* Closes: #35501

Authored-by: June Liu (Beyondsoft Corporation) <v-juneliu@microsoft.com>
Signed-off-by: Sutou Kouhei <kou@clear-code.com>
@kou kou changed the title [MSVC] Arrow failed to build with MSVC under /std:c++latest mode due to error C2280: 'std::basic_string<char,std::char_traits<char>,std::allocator<char>>::basic_string(std::nullptr_t)': attempting to reference a deleted function [C++][MSVC] Arrow failed to build with MSVC under /std:c++latest mode due to error C2280: 'std::basic_string<char,std::char_traits<char>,std::allocator<char>>::basic_string(std::nullptr_t)': attempting to reference a deleted function May 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants