[LLVMbugs] [Bug 11328] New: No implicit copy constructor is created for a volatile struct in a non-voatile struct
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Mon Nov 7 10:04:07 PST 2011
http://llvm.org/bugs/show_bug.cgi?id=11328
Bug #: 11328
Summary: No implicit copy constructor is created for a volatile
struct in a non-voatile struct
Product: clang
Version: trunk
Platform: PC
OS/Version: FreeBSD
Status: NEW
Severity: enhancement
Priority: P
Component: C++
AssignedTo: unassignedclangbugs at nondot.org
ReportedBy: yamagi at yamagi.org
CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
Classification: Unclassified
Created attachment 7587
--> http://llvm.org/bugs/attachment.cgi?id=7587
The testcase pasted into the description
When a volatile struct is embedded into a non-volatile struct, no or an
incorrect implicit copy constructor is created for the volatile struct. See
this code:
#include <iostream>
struct Test
{
int i;
Test(int _j, int _i)
{
i = _i;
foo.j = _j;
}
Test()
{
}
volatile struct Foo
{
int j;
} foo;
void print()
{
std::cout << i << " " << foo.j << std::endl;
}
};
int main()
{
Test b1(1, 2);
Test b2;
b2 = b1;
b2.print();
return 0;
}
While it compiles cleanly with g++ 4.6, clang++ emits an error:
yamagi at happy:pts/2 ~/temp: clang++ -std=c++11 -o test test.cc
test.cc:3:8: error: member function 'operator=' not viable: 'this' argument has
type 'volatile struct Foo', but function is not marked volatile
struct Test
^~~~
test.cc:17:18: note: 'operator=' declared here
volatile struct Foo
^
test.cc:33:5: note: implicit default copy assignment operator for 'Test' first
required here
b2 = b1;
^
1 error generated.
Exit 1
The version of clang++ is:
yamagi at happy:pts/2 ~/temp: clang++ -v
clang version 3.0 (branches/release_30 143612)
Target: x86_64-unknown-freebsd8.2
Thread model: posix
--
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
More information about the llvm-bugs
mailing list