Pelles C forum

Pelles C => Bug reports => Topic started by: neo313 on October 14, 2014, 11:27:22 PM

Title: Incorrect warning when using sizeof() on an local variable-length array
Post by: neo313 on October 14, 2014, 11:27:22 PM
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.



#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 ;
}