[Bug c++/36769] New: implicit conversion do not work

2008-07-09 Thread jia3ep at gmail dot com
Have to take place implicit convesion type1 to type2 to sss in function main()
in string:
 sss xxx = x;
But it works (workaround?) for only the following syntax:
 sss xxx( x );

All addition info follows (test4.ii includes all source required):

[EMAIL PROTECTED]:~/test$ g++ -v
Using built-in specs.
Target: i486-linux-gnu
Configured with: ../src/configure -v
--enable-languages=c,c++,fortran,objc,obj-c++,treelang --prefix=/usr
--enable-shared --with-system-zlib --libexecdir=/usr/lib
--without-included-gettext --enable-threads=posix --enable-nls
--with-gxx-include-dir=/usr/include/c++/4.2 --program-suffix=-4.2
--enable-clocale=gnu --enable-libstdcxx-debug --enable-objc-gc --enable-mpfr
--enable-targets=all --enable-checking=release --build=i486-linux-gnu
--host=i486-linux-gnu --target=i486-linux-gnu
Thread model: posix
gcc version 4.2.3 (Ubuntu 4.2.3-2ubuntu7)

[EMAIL PROTECTED]:~/test$ uname -a
Linux zork.elvees.com 2.6.24-19-server #1 SMP Wed Jun 18 15:18:00 UTC 2008 i686
GNU/Linux

[EMAIL PROTECTED]:~/test$ g++ test4.cpp -save-temps
test4.cpp: In function 'int main()':
test4.cpp:16: error: conversion from 'type1' to non-scalar type 'sss' requested

[EMAIL PROTECTED]:~/test$ cat test4.ii
# 1 "test4.cpp"
# 1 ""
# 1 ""
# 1 "test4.cpp"
struct type1 {
  type1() {};
};

struct type2 {
 type2( const type1& ) {};
};

struct sss {
  sss( type2 ) {
 };
};

int main() {
 type1 x;
 sss xxx = x;

 return 0;
}


-- 
   Summary: implicit conversion do not work
   Product: gcc
   Version: 4.2.3
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
    AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: jia3ep at gmail dot com


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



[Bug c++/36769] implicit conversion do not work

2008-07-09 Thread jia3ep at gmail dot com


--- Comment #2 from jia3ep at gmail dot com  2008-07-09 12:30 ---
Please, look at the following code. There are the same conversions, but it's
compiles and works without any errors. In the following sample takes place
implicit conversion 'int' to 'double' and then copy-initialization(that
requires implicit conversion too).
That's have to work in all cases(with type1/type2 and with int/double) in one
way.

struct sss {
  sss( double ) {
  };
};

int main() {
 int x = 7;
 sss xxx = x;

 return 0;
}

And finnaly look at the sample with template class. It's may compile or not
depending on what type will be selected:
struct type1 {
  type1() {};
};

struct type2 {
  type2( const type1& ) {};
};

template
struct sss {
  sss( T ) {
  };
};

int main() {
 int i = 7;
 sss xxx = i; // int to double works!

 type1 t;
 sss xxx2 = t; // type1 to type2 leads to compile time error!

 return 0;
}


-- 

jia3ep at gmail dot com changed:

   What|Removed |Added

 Status|RESOLVED|UNCONFIRMED
 Resolution|INVALID |


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