[Bug c++/62227] Templated move not elided
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62227 James Dennett james.dennett at gmail dot com changed: What|Removed |Added CC||james.dennett at gmail dot com --- Comment #2 from James Dennett james.dennett at gmail dot com --- A template cannot be a move constructor I'm with you so far. and so it is not legal to elide it. I don't think that's the case (or at least, I'm not aware of any wording saying so). C++98 effectively said so, but C++03/11/14 don't, AFAICS. Elision applies to copying/moving, not just to copy/move constructors, and a template can be used for copying or moving. The standard isn't very clear on this though.
[Bug c++/58162] [C++11] bogus error: use of deleted function 'constexpr A::A(const A)'
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58162 --- Comment #4 from James Dennett james.dennett at gmail dot com --- Thanks, Jason.
[Bug c++/58162] [C++11] bogus error: use of deleted function 'constexpr A::A(const A)'
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58162 James Dennett james.dennett at gmail dot com changed: What|Removed |Added CC||james.dennett at gmail dot com --- Comment #1 from James Dennett james.dennett at gmail dot com --- Jason pointed out to me that cv_unqualified() is more appropriate than TYPE_MAIN_VARIANT(), and I see that we might want to do the if (!CLASS_TYPE_P (type) cv_qualified_p (type)) type = cv_unqualified (type); dance to avoid needless work for other types.
[Bug c++/43663] Can't take a const-ref to a bit field
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43663 James Dennett james.dennett at gmail dot com changed: What|Removed |Added CC||james.dennett at gmail dot ||com --- Comment #6 from James Dennett james.dennett at gmail dot com 2011-05-15 11:52:01 UTC --- Here's a quick hack that causes a temporary to be generated when binding a bit-field to a reference-to-const. $ svn diff Index: call.c === --- call.c(revision 173769) +++ call.c(working copy) @@ -8594,7 +8594,7 @@ expr = error_mark_node; else { - if (!lvalue_or_rvalue_with_address_p (expr)) + if (is_bitfield_expr_with_lowered_type (expr) || !lvalue_or_rvalue_with_address_p (expr)) { tree init; var = set_up_extended_ref_temp (decl, expr, cleanup, init); I'll try to make time to clean that up and add regression tests before running it by someone with stronger gcc-fu.
[Bug c++/43663] Can't take a const-ref to a bit field
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43663 --- Comment #7 from James Dennett james.dennett at gmail dot com 2011-05-15 11:55:47 UTC --- Unsurprisingly the quick hack isn't really good enough -- it'll happily bind a non-const reference to a temporary initialized from a bitfield. (...and I guess that's why we have tests, and code reviews.)
[Bug c++/43663] Can't take a const-ref to a bit field
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43663 --- Comment #8 from James Dennett james.dennett at gmail dot com 2011-05-15 12:34:51 UTC --- Interestingly this works with Apple's g++ 4.2.1, specifically i686-apple-darwin10-g++-4.2.1 (GCC) 4.2.1 (Apple Inc. build 5666) (dot 3), but not with their 4.0.1 release. Tested with: int main() { struct S { S(): i(0) {} int i : 3; }; S s; printf(s: %p\n, (void*)s); int const cr(s.i); // should compile, binding to a temporary printf(cr: %p\n, (void*)cr); } A non-const reference still correctly gives an error: st.cc:12: error: invalid initialization of reference of type ‘int’ from expression of type ‘signed char:3’
[Bug c++/39415] static_cast used as downcast can silently lose const
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39415 James Dennett james.dennett at gmail dot com changed: What|Removed |Added CC||james.dennett at gmail dot ||com --- Comment #5 from James Dennett james.dennett at gmail dot com 2010-11-12 04:10:16 UTC --- Jason Merrill ja...@redhat.com has given me a heavy hint leading to the following smaller and much less ugly patch for cp/typeck.c that makes it more symmetrical with the reference case. This also passes my simple tests. .../gcc/cp $ svn diff Index: typeck.c === --- typeck.c(revision 164712) +++ typeck.c(working copy) @@ -5999,7 +5999,8 @@ base = lookup_base (TREE_TYPE (type), TREE_TYPE (intype), c_cast_p ? ba_unique : ba_check, NULL); - return build_base_path (MINUS_EXPR, expr, base, /*nonnull=*/false); + expr = build_base_path (MINUS_EXPR, expr, base, /*nonnull=*/false); + return cp_fold_convert(type, expr); } if ((TYPE_PTRMEM_P (type) TYPE_PTRMEM_P (intype))