[Bug c++/54023] New: [C++0x][initializer list] integer type to floating type narrowing type is not producing diagnostics

2012-07-18 Thread ebeworld at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54023

 Bug #: 54023
   Summary: [C++0x][initializer list] integer type to floating
type narrowing type is not producing diagnostics
Classification: Unclassified
   Product: gcc
   Version: 4.7.1
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
AssignedTo: unassig...@gcc.gnu.org
ReportedBy: ebewo...@gmail.com


According to standard 8.5.4.7

A narrowing conversion is an implicit conversion...
-from an integer type or unscoped enumeration type to a floating-point type,
except where the source is a constant expression and the actual value after
conversion will fit into the target type and will produce the original value
when converted back to the original type, ...

and not allowed at top level. Therefore followings should be generate
diagnostics

int i=3;
double d=i;
float f=i;
long double ld=i;

char c=3;
double d=c;

etc.. should give narrowing error.


[Bug c++/54023] [C++0x][initializer list] integer type to floating type narrowing type is not producing diagnostics

2012-07-18 Thread ebeworld at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54023

ebeworld  changed:

   What|Removed |Added

 Status|UNCONFIRMED |RESOLVED
 Resolution||INVALID

--- Comment #1 from ebeworld  2012-07-18 21:40:20 
UTC ---
forgot the curly braces.It should have been double d={i} and the compiler gives 
warning: narrowing conversion of 'i' from 'int' to 'double' inside { }
[-Wnarrowing]


[Bug c++/54074] New: [C++0x] initializer list accepts incorrect nested input

2012-07-23 Thread ebeworld at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54074

 Bug #: 54074
   Summary: [C++0x] initializer list accepts incorrect nested
input
Classification: Unclassified
   Product: gcc
   Version: 4.7.1
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
AssignedTo: unassig...@gcc.gnu.org
ReportedBy: ebewo...@gmail.com


#include
#include
using namespace std;

struct S1 {
int i;
string str;
};

//nested
struct S2 {
int i;
string str;
S1 s1;
};

int main() {
//should be S2 s22{ 3, "Hello3", {4,"Hello4"} }; 
//but it compiles
S2 s22{ 3, "Hello3", 4,"Hello4" };  
FINISH_TEST();
}


[Bug c++/54074] [C++0x] [DR 1270] initializer list accepts incorrect nested input

2012-07-31 Thread ebeworld at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54074

--- Comment #3 from ebeworld  2012-07-31 23:50:18 
UTC ---
Daniel, i agree with you and i wasnt reading the "elided" part of the document.
This is not a bug.


[Bug c++/54074] [C++0x] [DR 1270] initializer list accepts incorrect nested input

2012-07-31 Thread ebeworld at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54074

ebeworld  changed:

   What|Removed |Added

 Status|SUSPENDED   |RESOLVED
 Resolution||WONTFIX

--- Comment #4 from ebeworld  2012-07-31 23:51:01 
UTC ---
Daniel, i agree with you and i wasnt reading the "elided" part of the document.
This is not a bug.