D
dj3vande
Is this code, as the complete contents of a translation unit, valid C90
that initializes the struct foo to contain copies of the values passed
to bar()?
--------
struct foo
{
int i;
void *v;
};
int bar(int i,void *v)
{
struct foo f={i,v}; /*line 9*/
return f.i;
}
--------
GCC accepts it with -ansi, but complains about it with -ansi -pedantic:
--------
dj3vande@buttons:~ (0) $ gcc -ansi -pedantic -c foo.c
foo.c: In function 'bar':
foo.c:9: warning: initializer element is not computable at load time
foo.c:9: warning: initializer element is not computable at load time
dj3vande@buttons:~ (0) $ gcc -ansi -c foo.c
dj3vande@buttons:~ (0) $
--------
I can't find anything in N1124 that disallows it, though (I'm looking
at section 6.7.8, "Initialization"), and don't have a copy of C90 to
see whether it's changed since then.
dave
that initializes the struct foo to contain copies of the values passed
to bar()?
--------
struct foo
{
int i;
void *v;
};
int bar(int i,void *v)
{
struct foo f={i,v}; /*line 9*/
return f.i;
}
--------
GCC accepts it with -ansi, but complains about it with -ansi -pedantic:
--------
dj3vande@buttons:~ (0) $ gcc -ansi -pedantic -c foo.c
foo.c: In function 'bar':
foo.c:9: warning: initializer element is not computable at load time
foo.c:9: warning: initializer element is not computable at load time
dj3vande@buttons:~ (0) $ gcc -ansi -c foo.c
dj3vande@buttons:~ (0) $
--------
I can't find anything in N1124 that disallows it, though (I'm looking
at section 6.7.8, "Initialization"), and don't have a copy of C90 to
see whether it's changed since then.
dave