🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c++
Article #1335

Re: Non-Portable pointer assignment?

#1335
From: Joe Buck
Date: Tue, 18 Jun 1991 17:35
35 lines
1795 bytes
Tony Hansen writes:
|> .C++ has taken this tack: the type of 'x' is char while the type of 'xy' is
|> .int. It gives very nice properties when dealing with function and operator
|> .overloading.

In article <17163@darkstar.ucsc.edu>, daniel@cis.ucsc.edu (Daniel Edelson) writes:
|> Thank you for pointing this out. 
|> This means that the following program is legal in C++ and
|> ANSI C, and has different meanings in the two languages.
|> Am I correct in thinking that a design goal of Bjarne's was
|> to avoid the possibility of such a program? 

No, you aren't.  There are a number of deliberate differences.
The win from being able to say

	int foo;
	cout << "The answer is " << foo << '\n';

far exceeds the rare cases where a different answer is obtained
in C and C++.  You can still pass 'a' to a routine that expects
an int and have the right thing happen.

|> int main(void)
|> {
|> 	printf("%d\n", sizeof('a'));
|> }

But can you show me a real production program that produces
different answers?  People very rarely write sizeof('a').


--
Joe Buck
jbuck@galileo.berkeley.edu	 {uunet,ucbvax}!galileo.berkeley.edu!jbuck	
Technical Details
Message-ID: <1991Jun18.173559.4873@agate.berkeley.edu>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sun-barr!lll-winken!elroy.jpl.nasa.gov!swrinde!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!ucbvax!agate!forney.berkeley.edu!jbuck
References: <17163@darkstar.ucsc.edu>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sun-barr!lll-winken!elroy.jpl.nasa.gov!swrinde!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!ucbvax!agate!forney.berkeley.edu!jbuck
From: jbuck@forney.berkeley.edu (Joe Buck)
Newsgroups: comp.std.c++
Subject: Re: Non-Portable pointer assignment?
Keywords: 'a' and 'ab'
Message-ID: <1991Jun18.173559.4873@agate.berkeley.edu>
Date: 18 Jun 91 17:35:59 GMT
References: <17163@darkstar.ucsc.edu>
Sender: usenet@agate.berkeley.edu (USENET Administrator)
Reply-To: jbuck@forney.berkeley.edu (Joe Buck)
Organization: University of California, Berkeley
Lines: 35