On Tue, 13 May 2008 02:50:53 -0700, Greg Herlihy wrote:
> On May 13, 2:04 am, Lionel B <m...@[EMAIL PROTECTED]
> wrote:
>> On Tue, 13 May 2008 08:55:23 +0000, Lionel B wrote:
>> > On Mon, 12 May 2008 16:02:54 -0700, Greg Herlihy wrote:
>>
>> >> On May 12, 3:08 pm, Lionel B <m...@[EMAIL PROTECTED]
> wrote:
>>
>> >>> On my system (compiler GCC 4.1.2) with
>>
>> >>> float f = 139.4;
>>
>> >>> and compiled with:
>>
>> >>> g++ -std=c++98 -pedantic -Wall -Wextra
>>
>> >>> I get no warnings and the output is 'Expected result'. Should the
>> >>> compiler warn if there's an implicit conversion? Or only if it
>> >>> results in loss of precision?
>>
>> >> The g++ compiler can issue a warning if you want one:
>>
>> >> g++ -Wshorten-64-to-32
>>
>> > cc1plus: error: unrecognized command line option "-Wshorten-64-to-32"
>>
>> > GCC 4.3.0 on x86_64
>>
>> > Anyway, that doesn't sound like a floating-point warning...
>>
>> This does it: -Wconversion. With
>>
>> float f = 139.4;
>>
>> warning: conversion to ‘float’ alters ‘double’ constant value
>
> On my machine, using gcc (version 4.2.1 (Apple Inc. build 5559)) -
> Wconversion re****ts nothing.
> Whereas -Wshorten-64-to-32 re****ts:
>
> warning: implicit conversion shortens 64-bit value into a 32-bit
> value
Sure, I see that -Wshorten-64-to-32 is a Mac thing - it's all going to be
highly machine-specific. I'm surprised -Wconversion doesn't re****t
anything, though.
--
Lionel B


|