Version/Branch of Dear ImGui:
Version: top of tree
Branch: master
Back-end/Renderer/Compiler/OS
n/a
Compiler: gcc7
Operating System: n/a
My Issue/Question:
We are building with -Werror, on gcc 7, and have found that we need -Wclass-memaccess for gcc 7 as well. The particular line of code in imgui.h is here:
#elif defined(__GNUC__) && __GNUC__ >= 8
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wclass-memaccess"
#endif
Our problem is fixed by changing the comparison to __GNUC__ >= 7.
I am wondering if there is any reason the version check is set to 8 instead of 7?
I am wondering if there is any reason the version check is set to 8 instead of 7?
Because it’s really tricky to find the info of when a new warning was added (hence the mistake), and gcc seemingly hating developers they don’t have a “has_warning” system like Clang.
Could you submit a PR and make sure the same logic isn’t used elsewhere? Thank you!
I investigated when the flag was introduced. All the documentation says that the check was introduced in gcc8. I am going to find out why our gcc7 knows about it. Maybe someone patched our compiler with fixes from 8. If I can track this issue down to having a patched compiler, I will close this issue.
I installed mingw 7.3 to my local suite of compiler (until now I tested with mingw 5.1 and 8.1) and it doesn't take the -Werror=class-memaccess parameter here.
Another solution is to give up on the #if __GNUC__ >= x statement and just use #pragma GCC diagnostic ignored "-Wpragmas" which will disable the warning for an unknown warning disable.
That works, I appreciate the investigation. As you mentioned, the gcc documentation feels a bit inadequate as it doesn't indicate what is available in which version (https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html).
I found that we have a locally patched gcc, so the problem definitely exists at our end. We can disable the warning from our make system to work around the problem. At this point, I am ready to close this issue, if that matches your own inclination?
I think it would be suitable to switch to disabling the -Wpragmas warnings and move the GCC version tests to regular comments. I'd appreciate a PR otherwise I'll look into it later.
Pushed changes for this. Tested with mingw 5.1, 7.3, 8.1
Thanks! Apologies for not getting a PR together yet.
Most helpful comment
I think it would be suitable to switch to disabling the -Wpragmas warnings and move the GCC version tests to regular comments. I'd appreciate a PR otherwise I'll look into it later.