This is the mail archive of the gcc-bugs@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]

[Bug c++/36963] [4.4 Regression] Bogus narrowing conversion error in initializer list.



------- Comment #2 from chris dot fairles at gmail dot com  2008-08-02 18:41 -------
(In reply to comment #1)
> AFAIK, the error is a request of the c++0x standard and it seems -0.02435L does
> not fit exactly in a float while  -0.25L does, so the message is correct and I
> thus I don't think there is a bug here. 
> 
> Perhaps it should be a permissive error, so users can compile legacy code in
> c++0x mode.
> 
> CCing Jason.
> 

I think you are right. Section 8.5.4 - List-initialization, in the current WD
(N2691) says that a narrowing conversion from double to float is only allowed
if the conversion is of a literal value and the value can fit into the
destination type such that it produces the exact same value when coverted back.
Then from 8.5.4 paragraph 3, 3rd bullet, if any argument requires a narrowing
conversion, the program is ill-formed.

If you use the "f" post-fix in the test case, no narrowing conversion is
required and the error is not issued as expected.

This can be marked as invalid I believe.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36963


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