public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/25155]  New: Base type of expressions involving short operands is shown as int
@ 2005-11-29 16:05 santhosh dot selvaraj at wipro dot com
  2005-11-29 16:13 ` [Bug c/25155] " schwab at suse dot de
  0 siblings, 1 reply; 2+ messages in thread
From: santhosh dot selvaraj at wipro dot com @ 2005-11-29 16:05 UTC (permalink / raw)
  To: gcc-bugs

I don't know whether it is a bug or not.

Consider the following example:

short int sh1 = 1;
short int sh2 = 2;

printf("Size of short: %d\n", sizeof(short));
printf("Size of int: %d\n", sizeof(int));
printf("Size of expr: %d\n", sizeof(sh1+sh2));

Output:
Size of short: 2
Size of int: 4
Size of expr: 4

GCC is converting short to int while doing any arithmatic operation. Can anyone
explain why it is happening and where exactly(function) does this conversion
happen?


-- 
           Summary: Base type of expressions involving short operands is
                    shown as int
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: santhosh dot selvaraj at wipro dot com


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25155


^ permalink raw reply	[flat|nested] 2+ messages in thread

* [Bug c/25155] Base type of expressions involving short operands is shown as int
  2005-11-29 16:05 [Bug c/25155] New: Base type of expressions involving short operands is shown as int santhosh dot selvaraj at wipro dot com
@ 2005-11-29 16:13 ` schwab at suse dot de
  0 siblings, 0 replies; 2+ messages in thread
From: schwab at suse dot de @ 2005-11-29 16:13 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from schwab at suse dot de  2005-11-29 16:13 -------
This is the effect of the integer promotion rules.


-- 

schwab at suse dot de changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |INVALID


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25155


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2005-11-29 16:13 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-11-29 16:05 [Bug c/25155] New: Base type of expressions involving short operands is shown as int santhosh dot selvaraj at wipro dot com
2005-11-29 16:13 ` [Bug c/25155] " schwab at suse dot de

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).