🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #4055

Re: Converting between pointer types

#4055
From: Dan Pop
Date: Wed, 20 Sep 1995 10:50
29 lines
1646 bytes
In <43n718$ns@Radon.Stanford.EDU> becker@Xenon.Stanford.EDU (Denizen of the Deep) writes:


>My reading of the standard is that there's no way to convert between
>a pointer to a function and a pointer to an object or incomplete
>type; i.e. doing so results in undefined behavior.
>
>My question is this: suppose I am on a machine which has the
>same representation for all pointer types and I want to write
>code only for this machine (I don't care about portability).
>
>What is the status of my program if it attempts such a conversion,
>given that I know exactly how the compiler is generating code and I know
>it does exactly what I want?  Is it legal but just not portable, or is
>it not even technically a legal C program (since the behavior is
>undefined rather than implementation-defined)?

If the conversion is performed via an assignment, a constraint is violated
and a diagnostic is required.  If it is done with a cast, it's only a
matter of undefined behaviour.

In both cases, I'd say the code is not technically a legal C program.

Dan
--
Dan Pop
CERN, CN Division
Email: Dan.Pop@mail.cern.ch 
Mail:  CERN - PPE, Bat. 31 R-004, CH-1211 Geneve 23, Switzerland
Technical Details
Message-ID: <danpop.811594231@rscernix>
Path: arc1-ca.pugleaf.net!CERN.ch!rscernix!danpop
References: <43n718$ns@Radon.Stanford.EDU>

Show Full Headers
Complete Article Headers
Newsgroups: comp.std.c
Path: arc1-ca.pugleaf.net!CERN.ch!rscernix!danpop
From: Dan.Pop@mail.cern.ch (Dan Pop)
Subject: Re: Converting between pointer types
X-Nntp-Posting-Host: ues5.cern.ch
Message-ID: <danpop.811594231@rscernix>
Sender: news@news.cern.ch (USENET News System)
Organization: CERN European Lab for Particle Physics
X-Newsreader: NN version 6.5.0 #7 (NOV)
References: <43n718$ns@Radon.Stanford.EDU>
Date: Wed, 20 Sep 1995 10:50:31 GMT