Bug 36699 - not compile code, but must
Summary: not compile code, but must
Status: RESOLVED INVALID
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.1.2
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-07-02 16:43 UTC by alex
Modified: 2008-07-07 23:30 UTC (History)
2 users (show)

See Also:
Host: i386-redhat-linux
Target: i386-redhat-linux
Build: i386-redhat-linux
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description alex 2008-07-02 16:43:25 UTC
try compile:

#include <iostream>

template <typename T, size_t Count>
inline
size_t countof ( const T (&) [Count] )
{
  return Count;
}

int main(int argc, char* argv[])
{
  struct { int x1; int x2;} x [100];
  std::cout << countof(x) << std::endl;

  int y [101];
  std::cout << countof(y) << std::endl;

  struct Z { int x1; int x2;} z [102];
  std::cout << countof(z) << std::endl;

  std::cin.get();
  return 0;
}


gcc info(gcc -v):
Using built-in specs.
Target: i386-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-libgcj-multifile --enable-languages=c,c++,objc,obj-c++,java,fortran,ada --enable-java-awt=gtk --disable-dssi --enable-plugin --with-java-home=/usr/lib/jvm/java-1.4.2-gcj-1.4.2.0/jre --with-cpu=generic --host=i386-redhat-linux
Thread model: posix
gcc version 4.1.2 20070626 (Red Hat 4.1.2-14)
Comment 1 Wolfgang Bangerth 2008-07-07 23:30:58 UTC
Not a bug: type arguments to templates need to be *named* types with
external linkage. The declaration of 'x' uses an unnamed structure,
the declaration of 'z' a type of function-scope (and so internal) linkage.

W.