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

Make clang 10 compile #44752

Merged
merged 1 commit into from
Oct 9, 2020
Merged

Make clang 10 compile #44752

merged 1 commit into from
Oct 9, 2020

Conversation

Trioct
Copy link
Contributor

@Trioct Trioct commented Oct 9, 2020

Summary

SUMMARY: None

Purpose of change

I like when game compile

Describe the solution

Listen 2 compiler

Describe alternatives you've considered

Nuh-uh

Testing

Compiles

Additional context

I have literally no idea why the compiler wants this but it makes the code go
If someone has a deeper understanding of the clang voodoo please tell me (like you don't want const tripoint???)

src/magic_spell_effect.cpp:795:42: error: loop variable 'pair' has type 'const std::pair<int, tripoint> &' but is initialized with type 'std::pair<const int, tripoint>' resulting in a copy [-Werror,-Wrange-loop-construct]
    for( const std::pair<int, tripoint> &pair : targets_ordered_by_range ) {
                                         ^

src/magic_spell_effect.cpp:795:10: note: use non-reference type 'std::pair<int, tripoint>' to keep the copy or type 'const std::pair<const int, tripoint> &' to prevent copying
    for( const std::pair<int, tripoint> &pair : targets_ordered_by_range ) {
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

@Trioct Trioct requested a review from KorGgenT as a code owner October 9, 2020 04:48
@Trioct
Copy link
Contributor Author

Trioct commented Oct 9, 2020

I didn't request that review, but I hope you can handle this gargantuan workload
Edit: oh I see, there's a code owners file, cool

@KorGgenT KorGgenT added the <Bugfix> This is a fix for a bug (or closes open issue) label Oct 9, 2020
@Qrox
Copy link
Contributor

Qrox commented Oct 9, 2020

I have literally no idea why the compiler wants this but it makes the code go
If someone has a deeper understanding of the clang voodoo please tell me (like you don't want const tripoint???)

It's not voodoo, it's just because you're not supposed to modify the keys of a map, so when iterating through the elements of the map via std::pair, the key type has to be const, otherwise a copy is performed (like what the compiler says). What confuses me though is why GCC isn't warning about this.

@Trioct
Copy link
Contributor Author

Trioct commented Oct 9, 2020

Oh sure, didn't see it was iterating through a map and so returning a key and a value. I assumed it was a vector of pairs or something, makes much more sense.

@KorGgenT KorGgenT merged commit 7142d3b into CleverRaven:master Oct 9, 2020
@Trioct Trioct deleted the fix-clang-10 branch October 10, 2020 01:18
@anothersimulacrum anothersimulacrum added the Code: Build Issues regarding different builds and build environments label Nov 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
<Bugfix> This is a fix for a bug (or closes open issue) Code: Build Issues regarding different builds and build environments
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants