Re: how can i generate warnings for implicit casts that lose bits?



On Jun 6, 4:44 am, Chris Dollin <chris.dol...@xxxxxx> wrote:
robert bristow-johnson wrote:
here is a post i put out (using Google Groups) that got dropped by
google:

I'm going to ignore your real problem [1] in favour of criticising your
subject line:

... implicit casts ...

C doesn't have implicit casts.

the manual speaks of "explicit casts", then what is a cast that is not
an "explicit" cast? i think that

short a_short;
double a_double;
a_short = a_double;

is an "implicit cast". saying

a_short = (short)a_double;

is an "explicit cast." am i using the language incorrectly?

Casts are explicit syntax, `(Type) Expr`.
It has implicit /conversions/.

I'll have another latte now.

[1] Which I see has generated much -- hopefully helpful -- response.

i still haven't heard the magic invocation i make to the gcc compiler
that will warn me when an implicit conversion can potentially change a
value. the manual seems to say that -Wconversion should do it, but i
know that it does not, at least in my reasonably current
implementation of gcc on linux.

but i like to see the discussion it generated, anyway.

r b-j

.



Relevant Pages

  • Re: help with statistics library
    ... explicit casts are preferable to implicit casts, ... Just a nitpick of your nitpick of his nitpick: a cast is an explicit ... conversion, so "implicit cast" is a contradiction in terms. ... I accept that my preference for this way of avoiding the cast might be ...
    (comp.programming)
  • Re: what is meant by ?
    ... A cast operator supports implicit casts, so this could be written as: ... Prev by Date: ...
    (microsoft.public.vc.language)
  • Re: what is meant by ?
    ... >> A cast operator supports implicit casts, so this could be written as: ... I disagree - the cast just muddles things up. ...
    (microsoft.public.vc.language)
  • Re: Questions, please
    ... > Why might explicit casts on malloc's return value, ... sledgehammer to drive a screw. ... You may think that the cast means "convert the value of y from type ... BAR to type FOO". ...
    (comp.lang.c)
  • Re: help with statistics library
    ... explicit casts are preferable to implicit casts, ... Just a nitpick of your nitpick of his nitpick: a cast is an explicit ...
    (comp.programming)