Skip to content

Conversation

@avivajpeyi
Copy link
Collaborator

@avivajpeyi avivajpeyi commented Oct 28, 2025

@SimonStevenson is getting some new warnings when building

I am getting a new compiler warning with latest dev
warning: unknown warning option '-Wno-vla-cxx-extension'; did you mean '-Wno-vla-extension'? [-Wunknown-warning-option]

I see several new warnings when compiling COMPAS with latest dev:
Log.cpp:1323:22: warning: variable length arrays in C++ are a Clang extension [-Wvla-cxx-extension]
1323 | bool buf[bufSize];
| ^~~~~~~
Log.cpp:1323:22: note: read of non-const variable 'bufSize' is not allowed in a constant expression
Log.cpp:1272:13: note: declared here
1272 | size_t bufSize = p_H5file.dataSets[p_DataSetIdx].buf.size(); // size of write buffer
| ^
Log.cpp:1329:27: warning: variable length arrays in C++ are a Clang extension [-Wvla-cxx-extension]
1329 | short int buf[bufSize];
| ^~~~~~~
Log.cpp:1329:27: note: read of non-const variable 'bufSize' is not allowed in a constant expression
Log.cpp:1272:13: note: declared here
1272 | size_t bufSize = p_H5file.dataSets[p_DataSetIdx].buf.size(); // size of write buffer
| ^
Log.cpp:1336:21: warning: variable length arrays in C++ are a Clang extension [-Wvla-cxx-extension]
1336 | int buf[bufSize];
| ^~~~~~~
Log.cpp:1336:21: note: read of non-const variable 'bufSize' is not allowed in a constant expression
Log.cpp:1272:13: note: declared here
1272 | size_t bufSize = p_H5file.dataSets[p_DataSetIdx].buf.size(); // size of write buffer

I think we need different flags based on clang versions....
Clang < 17 → -Wno-vla-extension
Clang ≥ 17 → -Wno-vla-cxx-extension

(for context -- my Jetbrains IDE is what suggested me to use Wno-vla-cxx-extension in place of Wno-vla-extension

@github-actions
Copy link

✅ COMPAS Build Successful!

Item Value
Commit 07b9db8
Logs View workflow

Detailed Evolution Plot

Click to view evolution plot


Generated by COMPAS CI

@avivajpeyi avivajpeyi marked this pull request as ready for review October 28, 2025 01:18
@avivajpeyi
Copy link
Collaborator Author

Hey @jeffriley -- lets just foget about the changing flag for clang>18 for now? Ive left a comment in case this becomes an issue in the future.

@github-actions
Copy link

✅ COMPAS Build Successful!

Item Value
Commit 9ee3d79
Logs View workflow

Detailed Evolution Plot

Click to view evolution plot


Generated by COMPAS CI

Copy link
Collaborator

@jeffriley jeffriley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @avivajpeyi !

A few questions:

Why have you added -Wno-sign-compare? I think if we are generating these warnings we should fix the code - I know sometimes it's easier just to ignore the warning (or turn it off), but comparing a signed int to an unsigned (even size_t) is a bit of a code smell imo.

You've added -Wno-unused-variable - we should remove any unused variables, not just ignore their presence.

You've added -Wno-unused-parameter. Are you seeing any of these warnings (I'm not with gcc on linux)? For C++17 and later we can add the [[maybe_unused]] attribute. Not sure if that's available in clang (but I suspect it would be).

Ditto for -Wno-unused-function - although tbh we should remove any unused functions - if we find we need them later we can reinstate them from github.

You've added -Wno-reorder-ctor. Are you seeing any of these warnings (I'm not with gcc on linux)? If you are, we should fix the code - that's a bit of a code smell imo, and could cause problems in the future if there's a dependency on member initialisation.

Removed unnecessary warning suppressions from EXTRA_WARN_SUPPRESS.
@avivajpeyi
Copy link
Collaborator Author

OK -- lets just remove the extra warning-surpressment

@avivajpeyi avivajpeyi changed the title fix: add extra flags based on clang and some additional flags fix: add -Wno-vla-extension (note, -Wno-vla-cxx-extension might be needed in the future) Oct 28, 2025
Copy link
Collaborator

@jeffriley jeffriley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great - that works :-) Thanks!

@github-actions
Copy link

✅ COMPAS Build Successful!

Item Value
Commit f8d8326
Logs View workflow

Detailed Evolution Plot

Click to view evolution plot


Generated by COMPAS CI

@jeffriley jeffriley merged commit c18a089 into dev Oct 28, 2025
4 checks passed
@jeffriley jeffriley deleted the fix_buid_warnings branch October 28, 2025 02:11
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.

3 participants