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

unintialized error when building NeighborCommunicator.cpp #2615

Closed
Eric-Guiltinan opened this issue Aug 7, 2023 · 10 comments · Fixed by #3477
Closed

unintialized error when building NeighborCommunicator.cpp #2615

Eric-Guiltinan opened this issue Aug 7, 2023 · 10 comments · Fixed by #3477
Assignees
Labels
type: bug Something isn't working

Comments

@Eric-Guiltinan
Copy link

Eric-Guiltinan commented Aug 7, 2023

Describe the bug
An uninitialized error when building GEOS. Perhaps when building NeighborCommunicator.cpp. See screenshot

To Reproduce
Build TPLs and then GEOS on latest ubuntu with gcc 11.4.0 and cmake 3.24.1

Screenshots
image

Platform (please complete the following information):

  • Ubuntu 22.04.2 LTS
  • Compiler: gcc 11.4.0
  • GEOSX Version - latest version... cloned 8/3/23

Additional context
Built it in the same manner which was successful for us on 4/5/23

@Eric-Guiltinan Eric-Guiltinan added type: bug Something isn't working type: new A new issue has been created and requires attention labels Aug 7, 2023
@Eric-Guiltinan Eric-Guiltinan changed the title Your Title unintialized error when building GEOS Aug 7, 2023
@Eric-Guiltinan Eric-Guiltinan changed the title unintialized error when building GEOS unintialized error when building NeighborCommunicator.cpp Aug 7, 2023
@joshua-white
Copy link
Contributor

Hey @Eric-Guiltinan, the issue seems to be the FieldLocation enum is uninitialized here:
https://github.com/GEOS-DEV/GEOS/blob/514539bbd4a01f3f7c69ad684527aae6c86967dc/src/coreComponents/mesh/mpiCommunications/NeighborCommunicator.cpp#L507C1-L507C28

Could you try adding an additional Undefined element to the list here:
https://github.com/GEOS-DEV/GEOS/blob/514539bbd4a01f3f7c69ad684527aae6c86967dc/src/coreComponents/mesh/FieldIdentifiers.hpp#L31C1-L38C1

And then set FieldLocation location = FieldLocation::Undefined at line 507.

We should also maybe define default case behavior in the switch.

@joshua-white joshua-white self-assigned this Aug 7, 2023
@joshua-white joshua-white removed the type: new A new issue has been created and requires attention label Aug 8, 2023
@Eric-Guiltinan
Copy link
Author

That worked. We had to handle the undefined type in each of the switch statements as well. We just put them in as GEOS_ERROR ('Field Location is undefined') or something like that. Should we make a branch with the changes and submit a pull request?

@joshua-white
Copy link
Contributor

Yes, please. It would be good to have some other folks look at this. I am a little surprised this happened, as I thought enums always had a default value (0), but at least we know the fix. Regardless, it is good for us to catch potentially undefined behavior.

@klevzoff
Copy link
Contributor

klevzoff commented Aug 9, 2023

Yeah all switches on enums must have a default case with a GEOS_ERROR() call in it. Even if we always initialize enums with a value (we should), the compiler cannot prove at the location of switch statement that a particular enum has one of the predefined values handled by the switch cases, so it issues a warning that we treat as an error (and it's a good thing). Adding a default case should be sufficient to silence it.

I'm just surprised we haven't caught this before. Our CI has gcc-11.2 which is a bit older than 11.4, so maybe the warning was added somewhere in between. IMO we should always have the newest available gcc and clang versions in our CI matrix so we can stay on top of new compiler diagnostics as they are added.

@cssherman
Copy link
Contributor

@Eric-Guiltinan - Are you planning to submit a PR to address this issue, or should another dev do so?

@Eric-Guiltinan
Copy link
Author

Sorry, yeah, we made the edits on another account and will submit a PR on Monday morning.

@Eric-Guiltinan
Copy link
Author

I can't seem to push my branch to the repo. I think I don't have access. But I found the easiest fix for this was just to create a default case for the three switches in NearestNeighbor.cpp. I did not need to add the undefined case to FieldLocation as Josh suggested but maybe thats better.

image

@paveltomin
Copy link
Contributor

@Eric-Guiltinan where is the PR?

@joshua-white
Copy link
Contributor

@paveltomin, it seems easier for us to push a fix rather than @Eric-Guiltinan. this is on my todo list.

@joshua-white joshua-white self-assigned this Sep 21, 2023
@paveltomin
Copy link
Contributor

@joshua-white where is the PR?

paveltomin pushed a commit that referenced this issue Dec 5, 2024
paveltomin added a commit that referenced this issue Dec 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants