This is the mail archive of the gcc-patches@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: [RFC] Changes to the wide-int classes


On Sep 2, 2013, at 1:22 AM, Richard Sandiford <rdsandiford@googlemail.com> wrote:
> What I'm saying is that the assert stops plain:
> 
>   max_wide_int x = wide_int_var;

Sorry for being slow.  I see the point, indeed, from the preexisting code, we did:

  fixed_wide_int (const wide_int_ro w) : wide_int_ro (w) {
    /* We only allow the same size in, as otherwise                                            
       we would not know how to extend it.  */
    gcc_assert (precision == bitsize);
  }

to disallow it dynamically.  Doing this, or pushing it further into the type system so that it is caught a compile time, is fine.

I also like the passing of sign:

  max_wide_int x = max_wide_int::from (wide_int_var, SIGNED);
  max_wide_int x = max_wide_int::from (wide_int_var, UNSIGNED);

like this.  In the previous code we did:

  static inline fixed_wide_int from_wide_int (const wide_int& w) {
    if (w.neg_p (SIGNED))
      return w.sforce_to_size (bitsize);
    return w.zforce_to_size (bitsize);
  }

which is, as you point out, dangerous.

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