NO

Author Topic: Incorrect warning when using sizeof() on an local variable-length array  (Read 2384 times)

neo313

  • Guest
2046: Expression with no effect removed.
2046: Expression with no effect removed.

On lines where the sizeof operators are.

Nothing serious.
Bug is invariant of any project settings.

i can be anything: static, non-const, declared in for loop, or only known at runtime and the bug is there, as long as a vla array is used with a variable.

Code: [Select]

#include <stdlib.h>
#include <stdio.h>

int main( void )
{
const size_t i = 5 ;
char array[i] ;
const size_t size = sizeof( array ) ;
printf("%zu\n" , size ) ;
printf("%zu\n" , sizeof( array ) ) ;

return 0 ;
}
« Last Edit: October 14, 2014, 11:28:55 PM by neo313 »