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: [email protected]
ReportedBy: [email protected]
CC: [email protected], [email protected]
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@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@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.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs