[macstl-dev] gcc 3.3 on YellowDogLinux
Michael LeBlanc
leblanc at skycomputers.com
Fri Mar 25 21:42:59 WST 2005
> About the cast, is the intent just to change type? You don't want any
> code generated, do you?
A simple cast compiles. Here's the generated code code:
lis 11,_ZZNK9generatorILj0EEclEvE2un at ha
la 11,_ZZNK9generatorILj0EEclEvE2un at l(11)
lis 9,zz at ha
la 9,zz at l(9)
lvx 0,0,11
stvx 0,0,9
which is as simple as you can get. More silliness. On line 29 below,
replace "VUC" by "(VUC)", a C-style cast, and it draws a parse error.
1 #include <altivec.h>
2
3 #ifdef USE_TYPEDEF
4 typedef __vector unsigned int VUT;
5 typedef __vector unsigned char VUC;
6 #endif
7
8 template <unsigned int v0> struct generator
9 {
10 #ifdef USE_TYPEDEF
11 VUT
12 #else
13 __vector unsigned int
14 #endif
15 operator() () const
16 {
17 union union_type
18 {
19 unsigned int val [4];
20 __vector unsigned int vec;
21 };
22 static const union_type un = {v0, v0, v0, v0};
23 return un.vec;
24 }
25 };
26
27 __vector unsigned char zz =
28 // static_cast <VUC>
29 VUC
30 (generator <0> () ())
31 ;
More information about the macstl-dev
mailing list