🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #3529

Re: Integral promotion.

#3529
From: Norman Diamond
Date: Thu, 15 Feb 1996 14:46
18 lines
1530 bytes
In article <4fstj7$2l6@solutions.solon.com>, Rune Huseby <rune.huseby@gpi.telemax.no> writes:
>short test(short x1, short x2) {
>  short result;
>  result = x1 + x2;  /* Warning:  '=' : conversion from 'int '
>                         to 'short ', possible loss of data */
>My compiler [...] automagically converts my short-parameters to int's

No.  The addition operator "+" converts your short operands to ints.

The standard added the ability to prototype functions and clarified what
would happen if parameters are declared with non-promoted types, and this
is obeyed here.  It just happens to be irrelevant.  The "+" operator
promoted its operands even in pre-standard days.
--
 <<  If this were the company's opinion, I would not be allowed to post it.  >>
"I paid money for this car, I pay taxes for vehicle registration and a driver's
license, so I can drive in any lane I want, and no innocent victim gets to call
the cops just 'cause the lane's not goin' the same direction as me" - J Spammer
Technical Details
Message-ID: <4fvgvb$e0t@solutions.solon.com>
Path: arc1-ca.pugleaf.net!solon.com!not-for-mail
References: <4fstj7$2l6@solutions.solon.com>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!solon.com!not-for-mail
From: diamond@tko.dec.com (Norman Diamond)
Newsgroups: comp.std.c,comp.lang.c.moderated
Subject: Re: Integral promotion.
Date: 15 Feb 1996 08:46:03 -0600
Organization: Digital Equipment Corporation Japan , Tokyo
Sender: clc@solutions.solon.com
Approved: clc@solutions.solon.com
Message-ID: <4fvgvb$e0t@solutions.solon.com>
References: <4fstj7$2l6@solutions.solon.com>
Reply-To: diamond@jrdv04.enet.dec-j.co.jp (Norman Diamond)
NNTP-Posting-Host: solutions.solon.com