-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Disable buggy warnings #65542
Disable buggy warnings #65542
Conversation
How does this affect performance? At a glance this will switch a ton of valid references (at least for the lifetime of their call site) to making copies, for example stuff like map::get_known_connections will now potentially copy ter_t(vector + 2 sets + minor stuff) in an inner loop and itself is called in a loop, the change in output.cpp seems just plain weird |
Hi irwiss. I am quite a beginner at C++ so I might be doing some bad mistakes. If I understand the issue, GCC is not happy with using references from the chain of function calls as something needed for the rest of the function. The performance cost of my solution is indeed quite bad. Thank you for pointing it out, I will try to find a better way. What is the issue with the change in output.cpp? As I am not very accustomed with C++, there might be something I am missing. |
string_id and int_id act like pointers in this codebase(react to operator* and arrow), they'll call the .obj() to return a reference to the pointed-at object, these objects are valid after json data is loaded (happens just before savegame data loads), until game quits to main menu, i don't know of any exceptions to this I'm not sure what gcc13 complains about as i don't use it but likely the solution is to squelch that particular warning, either in makefile or somehow annotate .obj() function the output.cpp change is weird because you change from (allegedly) dangling reference warning to (allegedly) a dangling pointer, if that pleases the compiler then the compiler seems to be wrong |
944f0e5
to
8943784
Compare
I disabled that warning in the makefile. Is that what you wanted? |
That's one way although that completely eliminates even the may be valid results May be wrapping the specific function that raises the false positives in push/ignored/pop pragmas is an option, cursory google search appears to return a bunch of projects that resorted to pragma wraps for view/reference wrapper kind of classes i'm not sure why it's specifically ter/furn it complains about though, as it should complain about all types going through generic_factory::obj() 🤷♂️ |
Fixes #65449 I would also add |
As this is a keyword in C++20, it should be used to name a variable.
GCC 13 reports false positives of this warning.
a45aa9b
to
b9fad0a
Compare
As suggested by andrei8l
b9fad0a
to
db128ad
Compare
Summary
Infrastructure "Fix GCC warnings"
Purpose of change
When compiling the game, a lot of warnings (especial dangling reference warnings) were triggered. This is probably because I am using GCC 13.
Describe the solution
I performed some slight modifications to the code that don't change the final behavior but that please the compiler.
Describe alternatives you've considered
Testing
I tested in game the result of those changes to ensure that the game behavior is unchanged.
Additional context