Skip to content

-Wvla compiler warnings #44

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

Closed
zfields opened this issue Jul 18, 2024 · 3 comments
Closed

-Wvla compiler warnings #44

zfields opened this issue Jul 18, 2024 · 3 comments
Labels
conclusion: declined Will not be worked on topic: code Related to content of the project itself type: imperfection Perceived defect in any part of project

Comments

@zfields
Copy link

zfields commented Jul 18, 2024

Running this Arduino CLI command from the folder of a sketch that #includes the "Arduino_DebugUtils" library:

arduino-cli compile --verbose --warnings=all --build-property "build.extra_flags=-Wno-unused-variable -Wno-implicit-fallthrough -Wno-psabi -Wno-deprecated-copy -Wno-missing-field-initializers -Wno-delete-non-virtual-dtor -Wno-sign-compare -Og -g" --fqbn arduino:mbed_opta:opta

results in this compiler warning:

~/Development/Arduino/libraries/Arduino_DebugUtils/src/Arduino_DebugUtils.cpp: In member function 'void Arduino_DebugUtils::vPrint(const char*, va_list)':
~/Development/Arduino/libraries/Arduino_DebugUtils/src/Arduino_DebugUtils.cpp:139:28: warning: variable length array 'msg_buf' is used [-Wvla]
   char msg_buf[msg_buf_size];
                            ^
@zfields zfields changed the title -Wva compiler warnings -Wvla compiler warnings Jul 18, 2024
@arduino-libraries arduino-libraries deleted a comment from zfields Jul 19, 2024
@per1234 per1234 added type: imperfection Perceived defect in any part of project topic: code Related to content of the project itself labels Jul 19, 2024
@aentinger
Copy link
Contributor

Variable length arrays are not perfect, but a better solution than dynamic memory allocation on the heap. If you have a sensible design recommendation to eliminate a variable length array in this library (w/o resorting to heap) I'll be happy to review it.

@per1234 per1234 added the conclusion: declined Will not be worked on label Jul 19, 2024
@zfields
Copy link
Author

zfields commented Jul 19, 2024

@aentinger I have always used alloca() (auto-freed, stack allocation) in the past, but I'm not sure if that's available to all the embedded platforms you support.

https://www.man7.org/linux/man-pages/man3/alloca.3.html

@zfields
Copy link
Author

zfields commented Jul 19, 2024

If alloca() is not an option, then it would be good to document -Wvla as a required compiler flag.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
conclusion: declined Will not be worked on topic: code Related to content of the project itself type: imperfection Perceived defect in any part of project
Projects
None yet
Development

No branches or pull requests

3 participants