Re: Add some const decorations to prototypes

From: Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com>
To: Fabien COELHO <coelho(at)cri(dot)ensmp(dot)fr>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Add some const decorations to prototypes
Date: 2017-11-10 18:18:44
Message-ID: 256a6ce5-25a3-a296-9c0c-cd63953e83e7@2ndquadrant.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 11/10/17 11:42, Fabien COELHO wrote:
> After your explanation, and on third thoughts, ISTM that the assignment
> should not include "const" in the explicit cast, i.e., use
>
> extern void * msg_func(void);
> const char * msg = (char *) msg_func();
>
> The variable or field is constant, not what the function returns, so
>
> const char * msg = (const char *) msg_func();
>
> does not really make full sense to me, and moreover the compiler does not
> complain without the const.

The compiler knows how to handle the char * -> const char * case, but
not the char ** -> const char ** case.

--
Peter Eisentraut http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Graham Leggett 2017-11-10 18:34:05 [Patch] Log SSL certificate verification errors
Previous Message Tom Lane 2017-11-10 18:12:55 Re: Fix bloom WAL tap test