This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/60069] New: Different warning messages for -Wconversion with different optimization levels
- From: "chengniansun at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 05 Feb 2014 00:15:09 +0000
- Subject: [Bug c/60069] New: Different warning messages for -Wconversion with different optimization levels
- Auto-submitted: auto-generated
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60069
Bug ID: 60069
Summary: Different warning messages for -Wconversion with
different optimization levels
Product: gcc
Version: 4.9.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: chengniansun at gmail dot com
For the following code, gcc with -O0 emits a conversion warning, and gcc with
-O1 emits an overflow warning.
Does gcc have a similar policy to Clang that warnings should be not affected by
optimization levels?
$: cat s.c
void fn1() {
unsigned short *l_432;
const long l_448 = 70758;
*l_432 = +l_448;
}
$: gcc-trunk -O0 -c -Wconversion s.c
s.c: In function âfn1â:
s.c:4:12: warning: conversion to âshort unsigned intâ from âlong intâ may alter
its value [-Wconversion]
*l_432 = +l_448;
^
$: gcc-trunk -O1 -c -Wconversion s.c
s.c: In function âfn1â:
s.c:4:12: warning: large integer implicitly truncated to unsigned type
[-Woverflow]
*l_432 = +l_448;
^
$: gcc-trunk --version
gcc-trunk (GCC) 4.9.0 20140204 (experimental)
Copyright (C) 2014 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.