public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/63431] New: implicit conversion changes value but no warning ?
@ 2014-10-01 14:46 dcb314 at hotmail dot com
  2014-10-01 15:01 ` [Bug c++/63431] " redi at gcc dot gnu.org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: dcb314 at hotmail dot com @ 2014-10-01 14:46 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63431

            Bug ID: 63431
           Summary: implicit conversion changes value but no warning ?
           Product: gcc
           Version: 5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: dcb314 at hotmail dot com

Given C++ source code

extern void g(int);

void f(int p1)
{
    int i;

       if (p1 >= 0)
        i = 0.01;
    else
        i = -0.02;

     g(i);
}

trunk 20141001 says nothing, even with provocation:

$ ~/gcc/results/bin/g++ -c -O2 -Wall -Wextra oct1a.cc
$

Here is clang being a bit more helpful:

$ clang++ -c -O2 -Wall -Wextra oct1a.cc
oct1a.cc:9:7: warning: implicit conversion from 'double' to 'int' changes value
      from 0.01 to 0 [-Wliteral-conversion]
                i = 0.01;
                  ~ ^~~~
oct1a.cc:11:8: warning: implicit conversion from 'double' to 'int' changes
value
      from 0.02 to 0 [-Wliteral-conversion]
                i = -0.02;
                  ~  ^~~~
2 warnings generated.
$

There are half a dozen examples of this in Fedora's current Linux source code.


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2014-10-01 16:08 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-10-01 14:46 [Bug c++/63431] New: implicit conversion changes value but no warning ? dcb314 at hotmail dot com
2014-10-01 15:01 ` [Bug c++/63431] " redi at gcc dot gnu.org
2014-10-01 15:09 ` manu at gcc dot gnu.org
2014-10-01 16:08 ` dcb314 at hotmail dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).