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

Redundant condition #93

Open
PHackett opened this issue Feb 28, 2023 · 3 comments
Open

Redundant condition #93

PHackett opened this issue Feb 28, 2023 · 3 comments

Comments

@PHackett
Copy link

else if(way == ::std::ios_base::beg)

Line 127 is -
else if(way == ::std::ios_base::beg)

It is followed on line 129 -
else if(way != ::std::ios_base::beg)

Which, of course is always true given the previous test. This "impossible-redundant-condition" was spotted by a source analyser I used.

@jeking3
Copy link
Contributor

jeking3 commented May 15, 2024

I think the proper solution here is likely the following on lines 129, 130:

                else if(way != ::std::ios_base::cur || (which & ::std::ios_base::in) )
                    // (altering in&out is only supported if way is beg or end, not cur)

Similar to the logic on lines 110, 111:

                else if(way != ::std::ios_base::cur || (which & ::std::ios_base::out) )
                    // (altering in&out is only supported if way is beg or end, not cur)

@jeking3
Copy link
Contributor

jeking3 commented Jun 4, 2024

@PHackett any thoughts on this approach?

@PHackett
Copy link
Author

PHackett commented Jun 5, 2024

This was spotted by a static code analyser in an old version of boost - it was fixed in a later version.
I suggest that you look at newer versions of the library to see what fix was applied.

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

No branches or pull requests

2 participants