Skip to content

Conversation

@katrinafyi
Copy link
Contributor

@katrinafyi katrinafyi commented Feb 10, 2025

addresses warning present in recent clang versions (i was using clang 19).

souffle> /tmp/nix-build-souffle-2.4.1.drv-0/source/src/include/souffle/utility/SubProcess.h:81:29: warning: variable length arrays in C++ are a Clang extension [-Wvla-cxx-extension]
souffle>    81 |             char* argv_temp[argv.size() + 2];
souffle>       |                             ^~~~~~~~~~~~~~~
souffle> /tmp/nix-build-souffle-2.4.1.drv-0/source/src/include/souffle/utility/SubProcess.h:201:21: note: in instantiation of function template specialization 'souffle::execute<tcb::span<std::pair<const char *, const char *>> &, void>' requested here
souffle>   201 |     return souffle::execute(program, argv_ptr, envp_ptr);
souffle>       |                     ^
souffle> /tmp/nix-build-souffle-2.4.1.drv-0/source/src/MainDriver.cpp:165:17: note: in instantiation of function template specialization 'souffle::execute<std::map<const char *, std::string> &, void>' requested here
souffle>   165 |     auto exit = execute(binaryFilename, {}, env);
souffle>       |                 ^
souffle> /tmp/nix-build-souffle-2.4.1.drv-0/source/src/include/souffle/utility/span.h:473:56: note: function parameter 'argv' with unknown value cannot be used in a constant expression
souffle>   473 |     constexpr size_type size() const noexcept { return storage_.size; }
souffle>       |                                                        ^
souffle> /tmp/nix-build-souffle-2.4.1.drv-0/source/src/include/souffle/utility/SubProcess.h:81:29: note: in call to 'argv.size()'
souffle>    81 |             char* argv_temp[argv.size() + 2];
souffle>       |                             ^~~~~~~~~~~
souffle> /tmp/nix-build-souffle-2.4.1.drv-0/source/src/include/souffle/utility/SubProcess.h:67:61: note: declared here
souffle>    67 |         std::string const& program, span<char const* const> argv = {}, Envp&& envp = {}) {
souffle>       |                                                             ^

the VLA warnings have always existed but were recently added to the Wall group: https://ddanilov.me/default-non-standard-features/

addresses warning:
```cpp
souffle> /tmp/nix-build-souffle-2.4.1.drv-0/source/src/include/souffle/utility/SubProcess.h:81:29: warning: variable length arrays in C++ are a Clang extension [-Wvla-cxx-extension]
souffle>    81 |             char* argv_temp[argv.size() + 2];
souffle>       |                             ^~~~~~~~~~~~~~~
souffle> /tmp/nix-build-souffle-2.4.1.drv-0/source/src/include/souffle/utility/SubProcess.h:201:21: note: in instantiation of function template specialization 'souffle::execute<tcb::span<std::pair<const char *, const char *>> &, void>' requested here
souffle>   201 |     return souffle::execute(program, argv_ptr, envp_ptr);
souffle>       |                     ^
souffle> /tmp/nix-build-souffle-2.4.1.drv-0/source/src/MainDriver.cpp:165:17: note: in instantiation of function template specialization 'souffle::execute<std::map<const char *, std::string> &, void>' requested here
souffle>   165 |     auto exit = execute(binaryFilename, {}, env);
souffle>       |                 ^
souffle> /tmp/nix-build-souffle-2.4.1.drv-0/source/src/include/souffle/utility/span.h:473:56: note: function parameter 'argv' with unknown value cannot be used in a constant expression
souffle>   473 |     constexpr size_type size() const noexcept { return storage_.size; }
souffle>       |                                                        ^
souffle> /tmp/nix-build-souffle-2.4.1.drv-0/source/src/include/souffle/utility/SubProcess.h:81:29: note: in call to 'argv.size()'
souffle>    81 |             char* argv_temp[argv.size() + 2];
souffle>       |                             ^~~~~~~~~~~
souffle> /tmp/nix-build-souffle-2.4.1.drv-0/source/src/include/souffle/utility/SubProcess.h:67:61: note: declared here
souffle>    67 |         std::string const& program, span<char const* const> argv = {}, Envp&& envp = {}) {
souffle>       |                                                             ^
```
quentin
quentin previously approved these changes Feb 10, 2025
@quentin
Copy link
Member

quentin commented Feb 11, 2025

Hi, thanks for the fix!

@katrinafyi
Copy link
Contributor Author

No worries! The failing clang-format check isn't near the lines I've changed. Do you still want me to apply the style changes?

@quentin
Copy link
Member

quentin commented Feb 11, 2025

No worries! The failing clang-format check isn't near the lines I've changed. Do you still want me to apply the style changes?

Yes please. It happens because clang-format only runs on modified files, but the version of clang-format since the last check of this file may have changed and with that, sometimes, formatting rules get a slight update.

Ideally when something like this happens we should add a dedicated formatting rule in our project to fix the expected formatting.

clang-format -i src/include/souffle/utility/SubProcess.h
@quentin quentin merged commit 8ed1d22 into souffle-lang:master Feb 11, 2025
34 checks passed
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.

2 participants