typeof(obj)::size_type doesn't work

Haakon Riiser haakon.riiser@fys.uio.no
Sat Nov 22 23:13:00 GMT 2003


I don't know if this is a bug or not, so I'll ask here before I
submit it to GCC Bugzilla:

  $ cat test.cpp
  /****************************************************************/
  #include <vector>
  
  int main()
  {
      std::vector<int> v;
      typeof(v)::size_type s;
  }
  /****************************************************************/

  $ g++ test.cpp
  test.cpp: In function `int main()':
  test.cpp:7: syntax error before `;' token

If I replace

  typeof(v)::size_type s;

with

  typedef typeof(v) vtype;
  vtype::size_type s;

it compiles without errors or warnings.  GCC version:

  $ g++ -v
  Reading specs from /usr/lib/gcc-lib/i486-slackware-linux/3.2.3/specs
  Configured with: ../gcc-3.2.3/configure --prefix=/usr --enable-shared 
    --enable-threads=posix --enable-__cxa_atexit --disable-checking
    --with-gnu-ld --verbose --target=i486-slackware-linux
    --host=i486-slackware-linux
  Thread model: posix
  gcc version 3.2.3

Also verified on 3.3.2.

Is this a bug?  I always thought typeof(...) was supposed to be
just as good as the type defined with typedef.

-- 
 Haakon



More information about the Gcc-help mailing list