Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Shouldn't the solution be to suppress the warning by adding -Wno-array-bounds if GCC < 8? Or do something like
#pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Warray-bounds" ... #pragma GCC diagnostic pop
I don't think we want to disable the warnings for all files in Flang. I tried the pragma solution but it doesn't work in this case. Error are still triggered even the -Warray-bounds warning should be ignored.
In my opinion it would be okay to disable that warning for all of flang when compiling with GCC 7. The warning has proven to be unreliable and the valid warning situations can still be discovered by other compilers. The only risk is that someone developing with GCC 7 might introduce code that triggers a valid instance of this warning and it would go undetected until built with other compilers.
The advantage of having it in cmake code is that it doesn't clutter the C++ could with work-arounds.
Looking at examples in llvm, something like this might work:
if (CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 8.0) append("-Wno-array-bounds" CMAKE_CXX_FLAGS) endif()
flang/include/flang/Evaluate/integer.h | ||
---|---|---|
810 | Please be sure to run clang-format on the changes. |
Will there actually be a performance issue just leaving the code without disabling for other compilers? If other compilers weren't issuing this warning then they by definition know that the bounds check isn't necessary and therefore can optimize it out I'd have thought.
Yeah it could be the case. Should we maybe keep the workaround as in D81179 and just add a comment in case one performance problem comes out in the future?
I would prefer it that way but I don't really have strong opinions on it so don't consider me blocking or anything.
flang/lib/Decimal/big-radix-floating-point.h | ||
---|---|---|
182 | If compiling with other than G++, GNUC won't necessarily be defined, and will be replaced with 0, and the needless work-around will be enabled. I suggest #if defined __GNUC__ && __GNUC__ < 8. Please also use clang-format to make the code consistent; thanks. |
@klausler I had an outdated clang-format so that's why I had a bad formatting. Sorry for that. This should be fine now.
Please be sure to run clang-format on the changes.