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

Remove obsolete workaround for stdlib shuffle bug #44121

Merged
merged 2 commits into from
Sep 13, 2020

Conversation

kevingranade
Copy link
Member

@kevingranade kevingranade commented Sep 11, 2020

Summary

SUMMARY: None

Purpose of change

Now that the main block of Travis tests is passing again, the "try many variations" tests are running again, and some of them are failing. In particular the test that specifies _GLIBCXX_DEBUG is throwing a warning about an unused macro.
After clearing compilaion, GLIBCXX_DEBUG does what it's supposed to and reports invalid iterator handling, yay.

Describe the solution

I started to just silence the macro, but then realized that it might be a valid warning. Upon digging into the reason for the workaround and what has happened since, it looks like the reason for the workaround has been removed.
Also address the invalid pointer handling.

Describe alternatives you've considered

Silencing the error, but I think it's a real report.

Testing

Building would be nice.
The way we invoke catch in Travis exercises this feature, so a clean run of the failing test should be sufficient.

Additional context

I'm adding the test higher up i the travis build stages to exercise it more quickly.
This workaround was added by #27165
The need for it was removed by catchorg/Catch2#1908 and the import of the new code.

This workaround was added by #27165
The need for it was removed by catchorg/Catch2#1908 and the import of the new code.
.travis.yml Outdated Show resolved Hide resolved
@kevingranade kevingranade marked this pull request as draft September 12, 2020 01:21
@kevingranade
Copy link
Member Author

Sweet, this works, but I really want to clean up my commit history, hence putting it back in draft.

.travis.yml Outdated Show resolved Hide resolved
@kevingranade kevingranade force-pushed the kevingranade-remove-stdlib-shuffle-bug-workaround branch from a95e973 to 0c7bdf8 Compare September 12, 2020 03:30
@kevingranade kevingranade marked this pull request as ready for review September 12, 2020 03:31
Copy link
Contributor

@AMurkin AMurkin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be more logical.

src/mutation.cpp Outdated
@@ -130,16 +130,19 @@ void Character::toggle_trait( const trait_id &trait_ )
const trait_id trait = trait_;
const auto titer = my_traits.find( trait );
const auto miter = my_mutations.find( trait );
if( titer == my_traits.end() ) {
const bool found_in_traits = titer == my_traits.end();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const bool found_in_traits = titer == my_traits.end();
const bool not_found_in_traits = titer == my_traits.end();

src/mutation.cpp Outdated
@@ -130,16 +130,19 @@ void Character::toggle_trait( const trait_id &trait_ )
const trait_id trait = trait_;
const auto titer = my_traits.find( trait );
const auto miter = my_mutations.find( trait );
if( titer == my_traits.end() ) {
const bool found_in_traits = titer == my_traits.end();
const bool found_in_mutations = miter == my_mutations.end();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const bool found_in_mutations = miter == my_mutations.end();
const bool not_found_in_mutations = miter == my_mutations.end();

src/mutation.cpp Outdated
if( titer == my_traits.end() ) {
const bool found_in_traits = titer == my_traits.end();
const bool found_in_mutations = miter == my_mutations.end();
if( found_in_traits ) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if( found_in_traits ) {
if( not_found_in_traits ) {

src/mutation.cpp Outdated
my_traits.insert( trait );
} else {
my_traits.erase( titer );
}
if( ( titer == my_traits.end() ) != ( miter == my_mutations.end() ) ) {
// Checking this after toggling my_traits, if we exit the two are now consistent.
if( found_in_traits != found_in_mutations ) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if( found_in_traits != found_in_mutations ) {
if( not_found_in_traits != not_found_in_mutations ) {

src/mutation.cpp Outdated
debugmsg( "my_traits and my_mutations were out of sync for %s\n", trait.str() );
return;
}
if( miter == my_mutations.end() ) {
if( found_in_mutations ) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if( found_in_mutations ) {
if( not_found_in_mutations ) {

@kevingranade
Copy link
Member Author

Aha you're totally right, I'm going to apply your change manually to avoid extra commits.

GLIBCXX_DEBUG was complaining about comparing titer to my_traits.end() after calling my_traits.erase( titer ), as titer is invalidated.
@kevingranade kevingranade force-pushed the kevingranade-remove-stdlib-shuffle-bug-workaround branch from 0c7bdf8 to dc2fa7e Compare September 12, 2020 06:30
@ZhilkinSerg ZhilkinSerg added [C++] Changes (can be) made in C++. Previously named `Code` Code: Build Issues regarding different builds and build environments labels Sep 12, 2020
@ZhilkinSerg ZhilkinSerg merged commit af392f8 into master Sep 13, 2020
@kevingranade kevingranade deleted the kevingranade-remove-stdlib-shuffle-bug-workaround branch October 14, 2020 22:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[C++] Changes (can be) made in C++. Previously named `Code` Code: Build Issues regarding different builds and build environments
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants