4

When the size of my input is big enough, segmentation fault sprouts where variable-length arrays are used in a project. I want to remove them all, how to make GCC display every declaration it finds of a variable-length array?

I have tried using -Wstack-usage=1000 and filtering for the message warning: stack usage might be unbounded, but that gives me the function, not the declaration. Is there a better way?

5
  • 1
    use option -std=c89 -pedantic then warning: ISO C90 forbids variable length array Commented Mar 15, 2016 at 14:05
  • 1
    Removing all VLAs sound like overkill. You just need to remove oversized or VLAs with unpredictable size. Maybe you can grep them. Commented Mar 15, 2016 at 14:07
  • Well, I don't really consider a VLA where the size is a static const variable... Commented Mar 15, 2016 at 14:08
  • @BLUEPIXY Can't do that. Breaks for(int i = 0;.... Commented Mar 15, 2016 at 14:10
  • I'm mildly alarmed just how terrible the code has to be if knowing the function that contains the VLA is not enough. Commented Mar 15, 2016 at 21:15

1 Answer 1

8

I was pretty sure I have done that before, and thanks to the comments I found the solution again: use -Wvla compiler switch.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.