template<int* V> struct A { int i; A() { i = *V; } }; template<int& V> struct B { int i; B() { i = V; } };
int i; A< &i > ai; //OK B< i > bi; //OK struct S { int j, k; } s; A< &s.j > aj; //OK B< s.j > bj; //ERROR A< &s.k > ak; //ERROR B< s.k > bk; //ERROR int x[2]; A< &x[0] > a0; //OK B< x[0] > b0; //ERROR A< &x[1] > a1; //ERROR B< x[1] > b1; //ERROR int main() { return 0; } c:\devel\work>arm-uclibc-gcc -v Reading specs from /cygdrive/c/cygwin/arm-tools/bin/../lib/gcc-lib/arm-thumb-elf /3.3.1/specs Configured with: /home/Unknown/toolchain/build/gcc-3.3.1/configure --target=arm- thumb-elf --host=i686-pc-cygwin --build=i686-pc-cygwin --prefix=/arm-tools --exe c-prefix=/arm-tools --bindir=/arm-tools/bin --sbindir=/arm-tools/sbin --sysconfd ir=/arm-tools/etc --datadir=/arm-tools/share --localstatedir=/arm-tools/var --ma ndir=/arm-tools/man --infodir=/arm-tools/info --libdir=/arm-tools/lib --included ir=/arm-tools/include --with-local-prefix=/arm-tools/usr/local --with-gxx-includ e-dir=/arm-tools/include/c++ --enable-target-optspace --disable-nls --with-gnu-a s --with-gnu-ld --disable-__cxa_atexit --enable-languages=c,c++ --enable-shared --program-prefix=arm-uclibc- Thread model: single gcc version 3.3.1 c:\devel\work>arm-uclibc-gcc -c -mcpu=arm7tdmi -mthumb -gdwarf-2 -MD -Wa ll -Os -mapcs-frame -mthumb-interwork main.cpp main.cpp:9: error: `s.S::j' is not a valid template argument main.cpp:9: error: ISO C++ forbids declaration of `bj' with no type main.cpp:11: error: `s.S::k' is not a valid template argument main.cpp:11: error: ISO C++ forbids declaration of `bk' with no type main.cpp:12: error: `((&s) + 4)' is not a valid template argument main.cpp:12: error: it must be the address of an object with external linkage main.cpp:12: error: ISO C++ forbids declaration of `ak' with no type main.cpp:15: error: `x[0]' is not a valid template argument main.cpp:15: error: ISO C++ forbids declaration of `b0' with no type main.cpp:17: error: `x[1]' is not a valid template argument main.cpp:17: error: ISO C++ forbids declaration of `b1' with no type main.cpp:18: error: `((&x) + 4)' is not a valid template argument main.cpp:18: error: it must be the address of an object with external linkage main.cpp:18: error: ISO C++ forbids declaration of `a1' with no type main.cpp:2: confused by earlier errors, bailing out -- Summary: structure/array member reference/pointer as template argument Product: gcc Version: 3.3.1 Status: UNCONFIRMED Severity: minor Priority: P3 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: firda at seznam dot cz GCC build triplet: i686-pc-cygwin GCC host triplet: i686-pc-cygwin GCC target triplet: arm-thumb-elf http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36429