Typecast warnings

Marcelo Cantos marcelo@mds.rmit.edu.au
Wed Jan 7 20:44:00 GMT 1998


I've noticed that the following code:

  void f(char c);
  void g(int i) { f(i); }

which raised a truncation warning under Borland C++, doesn't rate a
mention under almost an Unix compiler regardless of warning settings.
Assuming I haven't missed a flag that does this already, would it take
much to add such a warning?


(If there is a need for a justification...)
We have found this to be a source of problems in our coding as we
move toward more abstract types.  We had a scripting language type:

  class AceInteger {
  private:
    uint32 value;
  };

which we wanted to change to:

  class AceInteger {
  public:
    typedef uint64 value_type;
  private:
    AceInt value;
  };

  typedef value_type AceInt;

We have found that it is dangerous to do this because programmers
need to be aware at all times what size type they are dealing with
to avoid inadvertently truncating values.  Hence, we have had to
leave the type explicitly as uint64 with no additional typedefs at
any level.


Cheers,
Marcelo

-- 
______________________________________________________________________
Marcelo Cantos, Research Assistant       __/_  marcelo@mds.rmit.edu.au
Multimedia Database Systems Group, RMIT   /       _ Tel 61-3-9282-2497
L2/723 Swanston St, Carlton VIC 3053, Aus/ralia ><_>Fax 61-3-9282-2490
Acknowledgements: errors - me; wisdom - God; sponsorship - RMIT



More information about the Gcc mailing list