Bug 56235 - [4.8 regression] Bogus "error: invalid conversion from ‘unsigned char’ to ‘B::Mode’ [-fpermissive]"
Summary: [4.8 regression] Bogus "error: invalid conversion from ‘unsigned char’ to ‘B:...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: unknown
: P3 normal
Target Milestone: 4.8.0
Assignee: Jason Merrill
URL:
Keywords: rejects-valid
Depends on:
Blocks:
 
Reported: 2013-02-07 05:15 UTC by Paul Pluzhnikov
Modified: 2013-02-07 17:15 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2013-02-07 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Paul Pluzhnikov 2013-02-07 05:15:31 UTC
Test case:

struct A
{
    A (const A &);
};

struct B
{
    A a;
    enum Mode { };
    Mode m:8;
};

struct C
{
    C();
    B b;
};

C fn()
{
    return C();
}


The test compiles fine with 4.7, fails with 4.8 (20130205 (experimental)) but only in C++11 mode:

g++ -c -std=c++11 t.ii
t.ii: In constructor ‘B::B(B&&)’:
t.ii:6:8: error: invalid conversion from ‘unsigned char’ to ‘B::Mode’ [-fpermissive]
 struct B
        ^
t.ii: In constructor ‘C::C(C&&)’:
t.ii:13:8: note: synthesized method ‘B::B(B&&)’ first required here 
 struct C
        ^
t.ii: In function ‘C fn()’:
t.ii:21:14: note: synthesized method ‘C::C(C&&)’ first required here 
     return C();
              ^


Google ref: b/8152830
Comment 1 Jakub Jelinek 2013-02-07 08:59:54 UTC
Started with http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=192813
Comment 2 Jason Merrill 2013-02-07 16:32:39 UTC
Author: jason
Date: Thu Feb  7 16:32:28 2013
New Revision: 195854

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=195854
Log:
	PR c++/56235
	* method.c (do_build_copy_constructor): Don't bother turning
	scalars from lvalues to xvalues.
	(do_build_copy_assign): Likewise.

Added:
    trunk/gcc/testsuite/g++.dg/init/bitfield4.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/method.c
Comment 3 Jason Merrill 2013-02-07 17:15:06 UTC
Fixed.