This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: ctor style cast vs c style cast


today i've run into this: if i cast a double value to an unsigned int
using the C style cast when passing it to printf, it's fine. however, if
i use the ctor style cast, i get a compile error. in theory, these two
should do the same: create a temporary unsigned int, and assign the
double to it after conversion, just the syntax is different. made a
little test, see attachment. plain int's are ok, but when qualified with
signed/unsigned the error occurs.

Hi,
I've run into this before, not sure if it's a bug, but what I do is use typedefs to work-around. (gcc has rejected your example on your error-marked lines for a long time)


Try the following for kicks:

typedef signed int      sint;
typedef unsigned int    uint;
typedef const int       cint;
typedef const sint      csint;
typedef const uint      cuint;

and replace them where you use ctor style initializations.

David Fang
Computer Systems Laboratory
Electrical & Computer Engineering
Cornell University
http://www.csl.cornell.edu/~fang/
	-- (2400 baud? Netscape 3.0?? lynx??? No problem!)


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]