Bug 13932 - [3.3 regression] duplicate warning message for conversion
Summary: [3.3 regression] duplicate warning message for conversion
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 3.4.0
: P2 normal
Target Milestone: 3.3.4
Assignee: Not yet assigned to anyone
URL:
Keywords: diagnostic
Depends on:
Blocks:
 
Reported: 2004-01-30 14:49 UTC by Wolfgang Bangerth
Modified: 2006-12-01 21:21 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2004-01-30 17:23:31


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Wolfgang Bangerth 2004-01-30 14:49:13 UTC
This little gem 
----------------- 
int i = 1.; 
----------------- 
yields 
  g/x> /home/bangerth/bin/gcc-3.4-pre/bin/c++ -c x.cc  
  x.cc:1: warning: initialization to `int' from `double' 
  x.cc:1: warning: argument to `int' from `double' 
which is not only duplicated, but also seems 
a) grammatically wrong in the first line (shouldn't it be 
   "initialization OF 'int' from 'double'"?) 
b) nonsensical in the second line: it's not an argument TO 
   a FUNCTION "int", it's the argument to the ASSIGNMENT 
   to int 
 
Highly bogus... 
 
This is a regression against 2.95 which simply said 
  g/x> /home/bangerth/bin/gcc-2.95.3/bin/c++ -c x.cc  
  x.cc:1: warning: initialization to `int' from `double' 
which is both short and precise. 
 
W.
Comment 1 Gabriel Dos Reis 2004-01-30 16:03:48 UTC
Subject: Re:  New: [3.3/3.4/3.5 regression] duplicate warning message for conversion

"bangerth at dealii dot org" <gcc-bugzilla@gcc.gnu.org> writes:

| This little gem 
| ----------------- 
| int i = 1.; 
| ----------------- 
| yields 
|   g/x> /home/bangerth/bin/gcc-3.4-pre/bin/c++ -c x.cc  
|   x.cc:1: warning: initialization to `int' from `double' 
|   x.cc:1: warning: argument to `int' from `double' 
| which is not only duplicated, but also seems 
| a) grammatically wrong in the first line (shouldn't it be 
|    "initialization OF 'int' from 'double'"?) 
| b) nonsensical in the second line: it's not an argument TO 
|    a FUNCTION "int", it's the argument to the ASSIGNMENT 
|    to int 
|  
| Highly bogus... 

Completely agreed.  Even more so, I think the diagnostic should NOT be
emitted when the compiler does know for sure that the target can
accurately hold the initializer with no loss (which is the case here).

Will look into this after 3.3.3

-- Gaby
Comment 2 Andrew Pinski 2004-01-30 17:23:30 UTC
Confirmed.
Comment 3 CVS Commits 2004-02-05 05:20:33 UTC
Subject: Bug 13932

CVSROOT:	/cvs/gcc
Module name:	gcc
Branch: 	gcc-3_4-branch
Changes by:	mmitchel@gcc.gnu.org	2004-02-05 05:20:31

Modified files:
	gcc/cp         : ChangeLog call.c typeck.c 
	gcc/testsuite  : ChangeLog 
Added files:
	gcc/testsuite/g++.dg/warn: conv2.C 

Log message:
	PR c++/13932
	* call.c (convert_like_real): Use "converting" rather than
	"argument" as the descriptive keyword to
	dubious_conversion_warnings.
	* typeck.c (convert_for_assignment): Do not call
	dubious_conversion_warnings.
	
	PR c++/13932
	* g++.dg/warn/conv2.C: New test.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.3892.2.36&r2=1.3892.2.37
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/call.c.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.452.2.5&r2=1.452.2.6
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/typeck.c.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.519.2.4&r2=1.519.2.5
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.3389.2.53&r2=1.3389.2.54
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/warn/conv2.C.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=NONE&r2=1.1.2.1

Comment 4 CVS Commits 2004-02-05 05:22:25 UTC
Subject: Bug 13932

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	mmitchel@gcc.gnu.org	2004-02-05 05:22:21

Modified files:
	gcc/cp         : ChangeLog call.c typeck.c 
	gcc/testsuite  : ChangeLog 
Added files:
	gcc/testsuite/g++.dg/warn: conv2.C 

Log message:
	PR c++/13932
	* call.c (convert_like_real): Use "converting" rather than
	"argument" as the descriptive keyword to
	dubious_conversion_warnings.
	* typeck.c (convert_for_assignment): Do not call
	dubious_conversion_warnings.
	
	PR c++/13932
	* g++.dg/warn/conv2.C: New test.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&r1=1.3936&r2=1.3937
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/call.c.diff?cvsroot=gcc&r1=1.457&r2=1.458
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/typeck.c.diff?cvsroot=gcc&r1=1.524&r2=1.525
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.3471&r2=1.3472
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/warn/conv2.C.diff?cvsroot=gcc&r1=1.1&r2=1.2

Comment 5 Mark Mitchell 2004-02-05 05:23:48 UTC
Fixed in GCC 3.4.
Comment 6 CVS Commits 2004-02-22 16:27:40 UTC
Subject: Bug 13932

CVSROOT:	/cvs/gcc
Module name:	gcc
Branch: 	gcc-3_3-branch
Changes by:	gdr@gcc.gnu.org	2004-02-22 16:27:38

Modified files:
	gcc/cp         : ChangeLog call.c typeck.c 
Added files:
	gcc/testsuite/g++.dg/warn: conv2.C 

Log message:
	Backport from mainline
	2004-02-04  Mark Mitchell  <mark@codesourcery.com>
	PR c++/13932
	* call.c (convert_like_real): Use "converting" rather than
	"argument" as the descriptive keyword to
	dubious_conversion_warnings.
	* typeck.c (convert_for_assignment): Do not call
	dubious_conversion_warnings.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.3076.2.249&r2=1.3076.2.250
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/call.c.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.341.2.38&r2=1.341.2.39
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/typeck.c.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.436.2.20&r2=1.436.2.21
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/warn/conv2.C.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=NONE&r2=1.2.6.1

Comment 7 Gabriel Dos Reis 2004-02-22 16:27:47 UTC
Backport fix from mainline.
Comment 8 Manuel López-Ibáñez 2006-07-08 13:22:30 UTC
Would not the following testcase be better?

int i=1.;
int j=1.1; // { dg-warning "" }

I can currently  handle this testcase in C front end with the code from the Wcoercion project. I am working in a patch for g++. 

What do you think? Should I reopen this or a new bug report or just send it to gcc-patches?