C++0x convertibility checking
Consider the folowing: class XXX { public: XXX(char) {} template XXX(T) = delete; }; fprintf(stderr, "ic::value = %i\n", std::is_convertible::value); fprintf(stderr, "ic::value = %i\n", std::is_convertible::value); The code above doesn't compile on gcc 4.6: In file included from /home/piotr.wyderski/f1/base/common.h:9:0, from /home/piotr.wyderski/f1/main.cpp:8: /opt/gcc-trunk-old2/bin/../lib/gcc/i686-pc-cygwin/4.6.0/include/c++/type_traits: In instantiation of `const bool std::__is_convertible_helper::__value': /opt/gcc-trunk-old2/bin/../lib/gcc/i686-pc-cygwin/4.6.0/include/c++/type_traits: 309:12: instantiated from `std::is_convertible' /home/piotr.wyderski/f1/main.cpp:219:81: instantiated from here /home/piotr.wyderski/f1/main.cpp:186:31: error: deleted function `XXX::XXX(T) [w ith T = double]' /opt/gcc-trunk-old2/bin/../lib/gcc/i686-pc-cygwin/4.6.0/include/c++/type_traits: 302:71: error: used here IMO it should result in an executable program which prints: ic::value =1 ic::value = 0 as double is obviously not convertible to XXX -- the "template XXX(T) = delete;" idiom: is very similar to an example from the N2346 proposal: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2346.htm "Removing dangerous conversions is as important as removing undesired language defaults. struct type { type( long long ); // can initialize with an long long type( long ) = delete; // but not anything less }; extern void bar( type, long long ); // and the same for bad overloads void bar( type, long ) = delete; // of free functions " Should I file a bug report or is it broken by design? A proposed fix is to remove the current template-based detector in the standard library and provide a built-in function __is_convertible which would check such corner cases in a much smarter way than is possible with templates: http://gcc.gnu.org/onlinedocs/gcc-4.4.2/gcc/Type-Traits.html#Type-Traits Best regards, Piotr Wyderski
Re: C++0x convertibility checking
Hi, > A proposed fix is to remove the current template-based detector in the > standard library and provide > a built-in function __is_convertible which would check such corner > cases in a much smarter way > than is possible with templates: I don't see why shouldn't be possible deal with this case with templates, seems a c++ front-end issue with extended sfinae. In general, if I see a compile time failure involving and there is no access control involved, like in the case at issue (those bits are still in the making) I always first suspect a glitch in the c++ front end sfinae bits. The issue may even be known or already fixed in mainline and 4.6. Paolo
Re: C++0x convertibility checking
Paolo Carlini wrote: > The issue may even be known or already fixed in mainline and 4.6. I confirm, the issue has already been fixed on the released version of 4.6. It exists on gcc versions 4.5.1 (official release) and 4.6.0 20100609 (experimental) (GCC). Best regards, Piotr Wyderski
Disabling Secondary Tests
The PPH project has tests that compile two different ways, and then compare the assembly. If either of the compiles fails, the comparison will fail. We'd like to simply not run the comparison. We currently have: set have_errs [llength [grep $test "{\[ \t\]\+dg-error\[\t\]\+.*\[ \t\]\+}"]] # Compile the file the first time for a base case. dg-test -keep-output $test "$options -I." "" if { $have_errs } { verbose -log "regular compilation failed" fail "$nshort $options, regular compilation failed" return } But that only stops subsequent actions when the test is known a priori to have errors. How do we detect compilation errors, so as to skip the remainder of the actions? -- Lawrence Crowl
Re: Disabling Secondary Tests
Lawrence Crowl writes: > The PPH project has tests that compile two different ways, and > then compare the assembly. If either of the compiles fails, the > comparison will fail. We'd like to simply not run the comparison. > > We currently have: > > set have_errs [llength [grep $test "{\[ \t\]\+dg-error\[\t\]\+.*\[ \t\]\+}"]] > # Compile the file the first time for a base case. > dg-test -keep-output $test "$options -I." "" > > if { $have_errs } { >verbose -log "regular compilation failed" >fail "$nshort $options, regular compilation failed" >return > } > > But that only stops subsequent actions when the test is known > a priori to have errors. How do we detect compilation errors, > so as to skip the remainder of the actions? I suppose you could grab test_counts(FAIL,count) before invoking dg-test and then see if it changed after. For extra security you could also check for ERROR, UNSUPPORTED, UNRESOLVED and UNTESTED. Ian
gcc-4.6-20110603 is now available
Snapshot gcc-4.6-20110603 is now available on ftp://gcc.gnu.org/pub/gcc/snapshots/4.6-20110603/ and on various mirrors, see http://gcc.gnu.org/mirrors.html for details. This snapshot has been generated from the GCC 4.6 SVN branch with the following options: svn://gcc.gnu.org/svn/gcc/branches/gcc-4_6-branch revision 174624 You'll find: gcc-4.6-20110603.tar.bz2 Complete GCC MD5=c97d52b2b4e6c8c5cf665ae3eb9e8e49 SHA1=a0bee5f2d63aa4e20a4e8648950c504b00114fac Diffs from 4.6-20110527 are available in the diffs/ subdirectory. When a particular snapshot is ready for public consumption the LATEST-4.6 link is updated and a message is sent to the gcc list. Please do not use a snapshot before it has been announced that way.