Open Quuxplusone opened 12 years ago
Bugzilla Link | PR11666 |
Status | NEW |
Importance | P enhancement |
Reported by | Richard Smith (richard-llvm@metafoo.co.uk) |
Reported on | 2011-12-27 20:52:55 -0800 |
Last modified on | 2013-02-13 23:51:50 -0800 |
Version | trunk |
Hardware | PC Linux |
CC | dgregor@apple.com, hstong@ca.ibm.com, i.galic@brainsware.org, llvm-bugs@lists.llvm.org |
Fixed by commit(s) | |
Attachments | |
Blocks | |
Blocked by | |
See also |
Right now we have code that looks schematically like so:
---
# include <inttypes.h>
# include <string.h>
template < typename T >
T& ink_zero(T& t) {
memset(&t, 0, sizeof(t));
return t;
}
struct Foo
{
union
{
struct
{
const char *m_ptr_method;
int16_t m_method_wks_idx;
} req;
struct
{
const char *m_ptr_reason;
int16_t m_status;
} resp;
} u;
};
int main ()
{
Foo *f = new Foo();
ink_zero(f->u);
}
---
When compiling with clang++ we get:
---
/opt/clang/bin/clang++ -Wall -Werror foo.cc -o foo
foo.cc:31:3: error: template argument uses unnamed type [-Werror,-Wunnamed-type-
template-args]
ink_zero(f->u);
^~~~~~~~
foo.cc:12:3: note: unnamed type used in template argument was declared here
union
^
1 error generated.
make: *** [foo] Error 1
---
_Bug 15265 has been marked as a duplicate of this bug._