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

Avoid some -Wshadow warnings in gcc12 #141

Merged
merged 1 commit into from
Oct 24, 2023

Conversation

rrsettgast
Copy link
Contributor

@rrsettgast rrsettgast commented Oct 21, 2023

When I was compiling camp with gcc12, I get the several of the following types of errors:

In file included from /usr/workspace/settgast/Codes/geosx/Shiva/tpl/camp/include/camp/camp.hpp:24,
                 from /usr/workspace/settgast/Codes/geosx/Shiva/src/common/types.hpp:12,
                 from /usr/workspace/settgast/Codes/geosx/Shiva/src/discretizations/unitTests/testLagrangeBasis.cpp:6:
/usr/workspace/settgast/Codes/geosx/Shiva/tpl/camp/include/camp/tuple.hpp: In function ‘constexpr camp::tuple_element_t<index, camp::tuple<Types ...> >& camp::get(const tuple<Types ...>&)’:
/usr/workspace/settgast/Codes/geosx/Shiva/tpl/camp/include/camp/tuple.hpp:440:29: error: declaration of ‘t’ shadows a global declaration [-Werror=shadow]
  440 | get(const tuple<Types...>&  t) noexcept
      |     ~~~~~~~~~~~~~~~~~~~~~~~~^
In file included from /usr/workspace/settgast/Codes/geosx/Shiva/tpl/camp/include/camp/value.hpp:14,
                 from /usr/workspace/settgast/Codes/geosx/Shiva/tpl/camp/include/camp/number/if.hpp:14,
                 from /usr/workspace/settgast/Codes/geosx/Shiva/tpl/camp/include/camp/number.hpp:15,
                 from /usr/workspace/settgast/Codes/geosx/Shiva/tpl/camp/include/camp/list/list.hpp:14,
                 from /usr/workspace/settgast/Codes/geosx/Shiva/tpl/camp/include/camp/list/at.hpp:16,
                 from /usr/workspace/settgast/Codes/geosx/Shiva/tpl/camp/include/camp/lambda.hpp:17,
                 from /usr/workspace/settgast/Codes/geosx/Shiva/tpl/camp/include/camp/camp.hpp:18:
/usr/workspace/settgast/Codes/geosx/Shiva/tpl/camp/include/camp/number/number.hpp:40:7: note: shadowed declaration is here
   40 | using t = num<true>;
      |       ^

I think that while this shouldn't be an actual problem, it is a valid warning. Changing the name of the parameter from t to tt avoids the shadowing.

edit: I am aware that I should be using target_include_directories with the SYSTEM specifier. I had made a mistake and didn't include SYSTEM, but I still think that this could be addressed in camp.

edit2: I figured out the build system is trying to compile the error.cpp file in camp. This is where the warning is coming up. I added the -Wno-shadow flag to the camp target, and this removes the warning. So there are workarounds.

@trws
Copy link
Member

trws commented Oct 23, 2023

I'd be good with working around this, really should probably be using prefixed names or something even but it's worth doing. It looks like all the checks were cancelled, and I'm not sure why. Is this ready for testing?

@rrsettgast
Copy link
Contributor Author

I'd be good with working around this, really should probably be using prefixed names or something even but it's worth doing. It looks like all the checks were cancelled, and I'm not sure why. Is this ready for testing?

I don't know why they were cancelled? I think it is ready. It is a trivial change. If you prefer prefixing the using t=num<true> then I can do that instead of what I did here.

@trws
Copy link
Member

trws commented Oct 23, 2023

Sadly that's a breaking change. I really would probably prefer it but it isn't something we can do instantly so I'll take this as is. Let me see if I can poke the builds to restart.

@trws trws merged commit 6e19b35 into LLNL:main Oct 24, 2023
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