W
William Ahern
So, GCC 4.01 is giving errors that GCC 3.3 did not, and I'm thinking they've
gone overboard with their new type checking infrastructure.
Here's the supposedly offending code (no laughing or grimacing, please
char *s, *s1;
s1 = strcpy((char [strlen(s) + 1]){ },s);
and GCC 4.01's error messages
error: compound literal has variable size
error: empty scalar initializer
error: (near initialization for `(anonymous)')
First, is it really illegal to define a variable size for the compound array
literal? Do compound literals and VLA's not mix? If I store the array length
in a variable I get the same error.
Second, what is up with "empty scalar initializer"? If I add an explicit
zero--{ 0 }--the error obviously goes away. Does the "as if zero" rule not
apply if no initializers are given?
I realize GCC behavior is off-topic, but I'm curious what the conensus is on
the proper behavior.
- Bill
gone overboard with their new type checking infrastructure.
Here's the supposedly offending code (no laughing or grimacing, please
char *s, *s1;
s1 = strcpy((char [strlen(s) + 1]){ },s);
and GCC 4.01's error messages
error: compound literal has variable size
error: empty scalar initializer
error: (near initialization for `(anonymous)')
First, is it really illegal to define a variable size for the compound array
literal? Do compound literals and VLA's not mix? If I store the array length
in a variable I get the same error.
Second, what is up with "empty scalar initializer"? If I add an explicit
zero--{ 0 }--the error obviously goes away. Does the "as if zero" rule not
apply if no initializers are given?
I realize GCC behavior is off-topic, but I'm curious what the conensus is on
the proper behavior.
- Bill