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++/51625] New: -Wconversion should be on by default, or at least included in -Wall


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


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