Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@undisputed-seraphim
Copy link
Contributor

@undisputed-seraphim undisputed-seraphim commented Sep 10, 2020

This PR aims to get rid of all shadowed variable warnings that occur in GCC during compilation.

Let me know if you would like me to change the naming of some of the changes I proposed.

[EDIT]
It seems that 2 or 3 of the unit tests are failing. It is clearly linked to the shadowed variable names being renamed and the shadowed variables being uncovered now.

I don't really have the willpower to track down exact failing functions, I would appreciate it if anyone can point out to me the offending changes.

Copy link
Owner

@fnc12 fnc12 left a comment

Choose a reason for hiding this comment

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

please make a PR from dev into dev

std::get<I>(lhs) = std::move(std::get<I>(rhs));
internal::static_if<std::integral_constant<bool, N != I + 1>{}>([](auto &lhs, auto &rhs) {
move_tuple_impl<N, I + 1>(lhs, rhs);
internal::static_if<std::integral_constant<bool, N != I + 1>{}>([](auto &l, auto &r) {
Copy link
Owner

Choose a reason for hiding this comment

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

I thought that shadowing in lambdas does not exist cause outer lhs and rhs do not cross with inner lhs and rhs

Copy link
Contributor Author

@undisputed-seraphim undisputed-seraphim Sep 10, 2020

Choose a reason for hiding this comment

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

It is a warning in GCC with -Wshadow and in Clang with -Wshadow-all.
It is possible that these warnings are false positives, but they are warnings nonetheless.
It is also possible that a future contributor carelessly adds a & to the lambda capture and then ignores the warnings :)

https://godbolt.org/z/WWjzzj

Copy link
Contributor Author

@undisputed-seraphim undisputed-seraphim Sep 10, 2020

Choose a reason for hiding this comment

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

I have made the requested changes. I'm also happy to report that all tests pass with the dev branch :)

I hope the fixes can be backported to a tagged release soon, I would like to use a tagged release if possible.

@undisputed-seraphim undisputed-seraphim changed the base branch from master to dev September 10, 2020 08:55
@fnc12
Copy link
Owner

fnc12 commented Sep 11, 2020

Please write changes in sources in dev folder, then run amalgamate script:

cd sqlite_orm
python third_party/amalgamate/amalgamate.py -c third_party/amalgamate/config.json -s .

@undisputed-seraphim
Copy link
Contributor Author

I have run the amalgamation script, but it produced much more changes than I expected.

Copy link
Owner

@fnc12 fnc12 left a comment

Choose a reason for hiding this comment

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

I've forgot to commit sqlite_orm.h. Please commit it too and then this PR can be merged

return static_cast<char>(std::toupper(static_cast<int>(c)));
});
static std::array<journal_mode, 6> all = {
static std::array<journal_mode, 6> all = {{
Copy link
Owner

Choose a reason for hiding this comment

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

why?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Because it is a compile error with GCC under the stricter modes I am using.
std::array does not have a constructor that takes an init-list. C++ standard suggests that the second braces can be elided, but the 'official' way is to use two sets of braces.
See https://stackoverflow.com/questions/8192185/using-stdarray-with-initialization-lists

@undisputed-seraphim
Copy link
Contributor Author

undisputed-seraphim commented Sep 14, 2020

I have run the amalgamation script, but it produced more changes than I expected and doesn't compile.

[EDIT]
Ah ok, it seems that running the script in Windows produces incorrect outputs.
I have re-run the script in Debian and the output looks correct now.

@fnc12 fnc12 merged commit 2757ed1 into fnc12:dev Sep 14, 2020
@fnc12
Copy link
Owner

fnc12 commented Sep 14, 2020

@undisputed-seraphim merged. Thank you!

@undisputed-seraphim undisputed-seraphim deleted the silence_warnings branch September 15, 2020 05:38
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

Successfully merging this pull request may close these issues.

2 participants