This is the mail archive of the cgen@sourceware.org mailing list for the CGEN 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: [PATCH] Make large enum constants unsigned


Hi -

> this fixes a bug noted in two threads on the binutils mailing list:
> https://sourceware.org/ml/binutils/2014-05/msg00152.html
> https://sourceware.org/ml/binutils/2014-05/msg00195.html
> 
> Both threads describe the problem pretty well, but the gist of it
> is that constants are generated that will be interpreted as signed.
> 
> 2014-05-22  Stefan Kristiansson  <stefan.kristiansson@saunalahti.fi>
> 
> 	* enum.scm (gen-enum-decl): Emit 'ULL' after constants larger than
> 	 #x80000000
> [...]

> -					(number->string (cadr e))
> +					(string-append (number->string (cadr e))
> +						       (if (> (cadr e)
> +							      #x80000000)
> +							   "ULL" ""))

Have you thought of having cgen emit it as

     (string-append "(signed int)" (number->string (cadr e)))

... or even find a number->string conversion function that takes into
account the destionation language's encoding constraints.

- FChE


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