Article View: comp.std.c++
Article #1336sizeof('a')
From: Brian M Kennedy
Date: Tue, 18 Jun 1991 21:04
Date: Tue, 18 Jun 1991 21:04
32 lines
1629 bytes
1629 bytes
>=daniel=>
>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?
>Is that design goal sufficiently important to motivate x3j16
>to change the type of 'c' to int?
>[... program exercising sizeof('a') ...]
Yes and no.
Yes, being consistent with C would have been a strong enough reason
for Bjarne to have made the type of 'c' be int in the first place,
EXCEPT that there is a stronger reason to have 'c' be char in C++:
overloading.
If I write:
cout << 'A';
cout << 65;
I want overload resolution to choose operator<<(ostream&, char) for
the first call and operator<<(ostream&, int) for the second. If 'A'
was type int then the first call would print the int value of A rather
than the character A. That would be very ugly.
This is discussed by E&S (ARM) on p.9, 2.5.2, in the annotations.
=======================================
== Brian M. Kennedy <bmk@csc.ti.com> ==
== Computer Systems Laboratory ========
== Computer Science Center ============
== Texas Instruments ==================
Technical Details
Message-ID:
<1991Jun18.210440.16325@csc.ti.com>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!swrinde!cs.utexas.edu!csc.ti.com!ti-csl!m2.csc.ti.com!bmkShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!swrinde!cs.utexas.edu!csc.ti.com!ti-csl!m2.csc.ti.com!bmk
From: bmk@m2.csc.ti.com (Brian M Kennedy)
Newsgroups: comp.std.c++
Subject: sizeof('a')
Message-ID: <1991Jun18.210440.16325@csc.ti.com>
Date: 18 Jun 91 21:04:40 GMT
Sender: bmk@csc.ti.com (Brian M Kennedy)
Distribution: usa
Organization: TI Computer Science Center, Dallas
Lines: 32