public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/51625] New: -Wconversion should be on by default, or at least included in -Wall
@ 2011-12-19 17:22 pnf at podsnap dot com
  2011-12-30  6:17 ` [Bug c++/51625] " pinskia at gcc dot gnu.org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: pnf at podsnap dot com @ 2011-12-19 17:22 UTC (permalink / raw)
  To: gcc-bugs

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

             Bug #: 51625
           Summary: -Wconversion should be on by default, or at least
                    included in -Wall
    Classification: Unclassified
           Product: gcc
           Version: 4.4.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: pnf@podsnap.com


Sometime after 4.1.2, conversion errors stopped being reported by default, and
in fact don't even show up with -Wall and -Wextra.  My opinion is that they
should be reported by default unless explicitly suppressed, but failing that,
at least they should be included in -Wall.

% cat boffo.C
#include <math.h>
#include <stdlib.h>
#include <stdio.h>
#include <cmath>
//using namespace std;
int main() {
  double x = abs(3.5), y= fabs(3.5);
  printf("%g %g\n",x,y);
  return 0;
}
% # No warning in 4.2.2 or 4.4.2
% /sbcimp/run/pd/gcc/32-bit/4.2.2/bin/g++ -Wextra -Wall  boffo.C
% /sbcimp/run/pd/gcc/32-bit/4.4.2/bin/g++ -Wextra -Wall  boffo.C
% # 4.1.2 warns, even without any option -W flags
% /sbcimp/run/pd/gcc/32-bit/4.1.2/bin/g++ -Wextra -Wall  boffo.C
boffo.C: In function 'int main()':
boffo.C:7: warning: passing 'double' for argument 1 to 'int abs(int)'
% /sbcimp/run/pd/gcc/32-bit/4.1.2/bin/g++ boffo.C
boffo.C: In function 'int main()':
boffo.C:7: warning: passing 'double' for argument 1 to 'int abs(int)'
# 4.2.2 and 4.4.2 warn correctly when -Wconversion turned on
% /sbcimp/run/pd/gcc/32-bit/4.2.2/bin/g++ -Wextra -Wall -Wconversion  boffo.C
boffo.C: In function 'int main()':
boffo.C:7: warning: passing 'double' for argument 1 to 'int abs(int)'
% /sbcimp/run/pd/gcc/32-bit/4.4.2/bin/g++ -Wextra -Wall -Wconversion  boffo.C
boffo.C: In function 'int main()':
boffo.C:7: warning: conversion to 'int' alters 'double' constant value


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

end of thread, other threads:[~2012-04-30 10:03 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-12-19 17:22 [Bug c++/51625] New: -Wconversion should be on by default, or at least included in -Wall pnf at podsnap dot com
2011-12-30  6:17 ` [Bug c++/51625] " pinskia at gcc dot gnu.org
2011-12-30  6:19 ` pinskia at gcc dot gnu.org
2011-12-30 17:27 ` pnf at podsnap dot com
2012-04-29 12:17 ` broken.zhou at gmail dot com
2012-04-29 21:56 ` manu at gcc dot gnu.org
2012-04-30  9:12 ` pnf at podsnap dot com
2012-04-30 10:03 ` redi at gcc dot gnu.org

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).