🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #4454

Re: giving a (*)(const void *) to a (*)(void *)

#4454
From: Tanmoy Bhattacharya
Date: Fri, 08 Dec 1995 16:05
32 lines
1828 bytes
In article <Dominique.Marcadet-0712951751160001@marcadet.supelec.fr>,
Dominique.Marcadet@supelec.fr (Dominique Marcadet) writes: 
|> The following code compiles fine without any warning with the latest g++,
|> but gcc emits a warning and other C compilers say it's an error.
|> 
|> Is it really wrong according to the C standard ?
|> 
|> extern void f (void (*) (void *));
|> 
|> extern void g (const void *);
|> 
|> void h ()
|> {
|>         f (&g);
|> }

Yes, nowhere in the standard do I see that `const' can be ignored in this
context. It is true that this could have been allowed without adversely
affecting typesafety (I haven't gone through a formal proof: so I may be
wrong): but I believe it has not been done. const is an afterthought in the C
standard (or so it seems :-) and in more than one place, simplicity of the
rules has been favoured over the maximum flexibility to the programmer.

Cheers
Tanmoy
-- 
tanmoy@qcd.lanl.gov(128.165.23.46) DECNET: BETA::"tanmoy@lanl.gov"(1.218=1242)
Tanmoy Bhattacharya O:T-8(MS B285)LANL,NM87545 H:#9,3000,Trinity Drive,NM87544
Others see <gopher://yaleinfo.yale.edu:7700/00/Internet-People/internet-mail>,
<http://alpha.acast.nova.edu/cgi-bin/inmgq.pl>or<ftp://csd4.csd.uwm.edu/pub/
internetwork-mail-guide>. -- <http://nqcd.lanl.gov/people/tanmoy/tanmoy.html>
fax: 1 (505) 665 3003   voice: 1 (505) 665 4733    [ Home: 1 (505) 662 5596 ]
Technical Details
Message-ID: <4a9nnm$h9b@newshost.lanl.gov>
Path: arc1-ca.pugleaf.net!qcd.lanl.gov!tanmoy
References: <Dominique.Marcadet-0712951751160001@marcadet.supelec.fr>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!qcd.lanl.gov!tanmoy
From: tanmoy@qcd.lanl.gov (Tanmoy Bhattacharya)
Newsgroups: comp.std.c
Subject: Re: giving a (*)(const void *) to a (*)(void *)
Date: 8 Dec 1995 16:05:10 GMT
Organization: Los Alamos National Laboratory
Distribution: world
Message-ID: <4a9nnm$h9b@newshost.lanl.gov>
References: <Dominique.Marcadet-0712951751160001@marcadet.supelec.fr>
NNTP-Posting-Host: qcd.lanl.gov