This is the mail archive of the
gsl-discuss@sources.redhat.com
mailing list for the GSL project.
Re: const qualifier on function return types.
- To: Lowell Johnson <ldjohn at usgs dot gov>
- Subject: Re: const qualifier on function return types.
- From: Brian Gough <bjg at network-theory dot co dot uk>
- Date: Sat, 16 Jun 2001 00:28:52 +0100 (BST)
- Cc: gsl-discuss at sources dot redhat dot com
- References: <01061510380302.06977@edclxw5>
Lowell Johnson writes:
> cc-3303 cc: WARNING File = ../gsl/gsl_vector_double.h, Line = 78
> A type qualifier on a return type is meaningless.
>
> I searched the mailing list archive and saw a short discussion of
> this and whether it is ANSI C. I didn't see any mention of the
> reason for applying the const qualifier.
> What is the purpose of applying a const qualifier to a return
> value? Is it so that we can see the return value but not change
> it?
That was the intention, but it doesn't work. The const on those
return types is meaningless, as the compiler says.
The cause of the warnings is functions like
const gsl_vector gsl_vector_const_view (const gsl_vector * v, ..)
The logic behind the return type was to preserve constness when
creating vector views, so that a view of a "const gsl_vector *" would
also be const. It doesn't actually work because the views are
returned as structs and C doesn't preserve constness when copying
structs.
I'll have to do something about it .. it is unsatisfactory right now.