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

Compiler error in output serializer due to 'incompatible initializer' #3081

Closed
1 of 3 tasks
Neumann-A opened this issue Oct 14, 2021 · 5 comments · Fixed by #3082
Closed
1 of 3 tasks

Compiler error in output serializer due to 'incompatible initializer' #3081

Neumann-A opened this issue Oct 14, 2021 · 5 comments · Fixed by #3082
Assignees
Labels
confirmed kind: bug release item: 🐛 bug fix solution: proposed fix a fix for the issue has been proposed and waits for confirmation

Comments

@Neumann-A
Copy link

What is the issue you have?

Code does not compile in GA (windows-2019 using clang-cl 13.0.0). I see the following compiler error:

D:\a\AllProjects\AllProjects\b\vcpkg_installed\x64-windows-llvm-release\include\nlohmann/detail/output/serializer.hpp(814,25): error: variable 'end' with type 'auto *const' has incompatible initializer of type 'std::_Array_iterator<char, 64>'
            auto* const end = std::remove(number_buffer.begin(),
                        ^     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
D:\a\AllProjects\AllProjects\b\vcpkg_installed\x64-windows-llvm-release\include\nlohmann/detail/output/serializer.hpp(824,25): error: variable 'dec_pos' with type 'auto *const' has incompatible initializer of type 'std::_Array_iterator<char, 64>'
            auto* const dec_pos = std::find(number_buffer.begin(), number_buffer.end(), decimal_point);
                        ^         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 warning and 2 errors generated.

Which compiler and operating system are you using?

Current GA windows-2019
https://github.com/actions/virtual-environments/blob/main/images/win/Windows2019-Readme.md

  • Compiler: clang-cl 13.0.0
  • Operating system: Windows

Which version of the library did you use?

  • latest release version 3.10.3
  • other release - please state the version: 3.10.2
  • the develop branch

I couldn't reproduce it locally but my setup does not completely match GA. Simply changing the auto* const to auto only will probably solve the problem.

@nlohmann
Copy link
Owner

  • What did you try to compile?
  • Please describe the steps to reproduce the issue. Can you provide a small but working code example?

@nlohmann nlohmann added the state: needs more info the author of the issue needs to provide more details label Oct 14, 2021
@Neumann-A
Copy link
Author

I deleted those points because I cannot give a satisfying answer to those.

I'll can give you a stackoverflow link with a similar problem though:
https://stackoverflow.com/questions/68643140/auto-const-has-incompatible-initializer-of-type-std-array-iteratorchar-48

From that it should be clear that the current code has an invalid assumption baked in.

@nlohmann
Copy link
Owner

The problem was introduced in #2561 and was the result of "fixing" Clang-Tidy warnings.

The code has to be changed back to

const auto end = std::remove(number_buffer.begin(),
                             number_buffer.begin() + len, thousands_sep);

and

const auto dec_pos = std::find(number_buffer.begin(), number_buffer.end(), decimal_point);

@nlohmann nlohmann self-assigned this Oct 15, 2021
@nlohmann nlohmann added confirmed and removed state: needs more info the author of the issue needs to provide more details labels Oct 15, 2021
@nlohmann nlohmann added release item: 🐛 bug fix solution: proposed fix a fix for the issue has been proposed and waits for confirmation labels Oct 16, 2021
@nlohmann nlohmann added this to the Release 3.10.4 milestone Oct 16, 2021
@nlohmann
Copy link
Owner

I @Neumann-A I created a fix in #3082. Can you please verify this works for you?

@Neumann-A
Copy link
Author

I can verify that const auto works because I already applied that patch/change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
confirmed kind: bug release item: 🐛 bug fix solution: proposed fix a fix for the issue has been proposed and waits for confirmation
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants