Skip to content

indeterminate array size warning for sizeof does not output the symbol name #338

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
1 of 3 tasks
YashasSamaga opened this issue Jul 8, 2018 · 1 comment
Closed
1 of 3 tasks

Comments

@YashasSamaga
Copy link
Member

YashasSamaga commented Jul 8, 2018

Is this a BUG REPORT, FEATURE REQUEST or QUESTION?:

  • Bug Report
  • Feature Request
  • Question

What happened:

warning 224: indeterminate array size in "sizeof" expression (symbol "")

The warning says symbol "".

What you expected to happen:

It must give the correct name of the symbol.

How to reproduce it (as minimally and precisely as possible):

f(arr[]) {
  sizeof(arr);
}
main () { 
 f("");
}

Environment:

  • Operating System: Windows 10
  • Compiler version: 3.10.8
@YashasSamaga
Copy link
Member Author

YashasSamaga commented Jul 8, 2018

Hint 1:
The function lex is used to invoke the lexer. It takes two arguments: pointer to a cell called lexvalue and a pointer to a char* called lexsym. It returns the token id and sets lexvalue to a number if it had just read a number or it sets lexsym if it had read a symbol. Internally, the lexer just copies an internal pointer (_lexstr) to *lexsym.

Suppose you read a symbol and obtained the name of the symbol through lexsym parameter. On the next invocation of lex, it may happen that your previous pointer contains something new (which could be "") instead of the old symbol.

By using that pointer to display an error message, you might not get expected results.

Hint 2:
The file sc5.c is the component which deals with displaying errors and warnings. The function which is used throughout the compiler codebase to trigger a warning is int error(int number,...). The number parameter takes the error/warning number. Despite being called error, it also issues warnings.

You can use your editor's search in all files function to find parts of the compiler which issue warning 224 by searching for error(224.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant