From mboxrd@z Thu Jan 1 00:00:00 1970 From: Brian Gough To: Lowell Johnson Cc: gsl-discuss@sources.redhat.com Subject: Re: const qualifier on function return types. Date: Wed, 19 Dec 2001 13:20:00 -0000 Message-id: <15146.39476.608398.5090@debian> References: <01061510380302.06977@edclxw5> X-SW-Source: 2001/msg00223.html 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.