This is the mail archive of the
gsl-discuss@sources.redhat.com
mailing list for the GSL project.
Re: Problem building vector/reim_source.c
gsl-discuss@lists.thewrittenword.com writes:
> > {
> > gsl_vector_long_double_const_view view = { { 0 , 0 , 0 , 0 } };
> > (( gsl_vector_long_double_view *)(&view))->vector = s;
> > return view;
> > }
> > }
> >
> > So, the Solaris C compiler isn't allowing you to throw away the
> > const'ness of view (seems correct to me). I tried compiling with the
> > native compilers on Tru64 UNIX, IRIX, HP, and AIX and they all accept
> > the construct above.
>
> Actually, it's complaining about "return view".
Right.
I believe the Solaric C compiler is incorrect on this point.
I should have added this to the release notes but forgot (now added).
For more info see my recent post on comp.std.c and Eric Rose's
and my posts on comp.lang.c.moderated.
I think they are misinterpreting section 6.6.6.4,
If a return statement with an expression is executed the value of
the expression is returned to the caller as the value of the
function call expression. If the expression has a type different
from that of the function in which it appears, it is converted as
if it were assigned to an object of that type.
It looks like they are applying the second rule, since the '=' sign in
the error message indicates assignment. This results in an error,
since the return type is a struct containing a const element.
However, the expression type is the same as the function type, so this
rule should not be applied here.
regards
Brian Gough