C: Another type promotion question

Page 2 - Seeking answers? Join the AnandTech community: where nearly half-a-million members share solutions and discuss the latest tech.

Cat

Golden Member
Oct 10, 1999
1,059
0
0
LOL. The point is, it could have been something else. I'm not trusting someone that refers to a signed int as 31 bits of storage, and believes that MSVC++ is even close to standards compliance. :) Well, 7.1 is getting there.

The standards could have been updated, the pages we found might have had typos, hell, it could have been something iffy with his Linux compile of splint.

All I'm saying is, never assume anything when it comes to programming. That's why we asked the author, who has access to many builds of splint, and knows more than all 3 of us put together when it comes to language design.

Anyway, dropping into a civil thread and doing the equivalent of "nyah nyah" is pretty lame.
 

Ameesh

Lifer
Apr 3, 2001
23,686
1
0
refers to a signed int as 31 bits of storage, and believes that MSVC++

thats actually what the compiler spits out as a warning when shoving an unsigned int into a signed one. considering a int is 4 bytes on x86 and a signed int reseves a bit for sign its relativly accurate. so "nyah nyah"
 

Cat

Golden Member
Oct 10, 1999
1,059
0
0
No it doesn't. The code you provided compiles with no warnings with warning level 4, on both MSVC6.0 SP5 and MSVC7.0.

The warning it WOULD produce if any, would be "warning: conversion from 'larger type' to 'smaller type', possible loss of data.

Yes, you lose a bit of precision because of the sign. No, you don't get bit-specific warnings.