This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
c++/539: Incorrect type mismatch error reported for static members in templates
- To: gcc-gnats at gcc dot gnu dot org
- Subject: c++/539: Incorrect type mismatch error reported for static members in templates
- From: chase at ece dot utexas dot edu
- Date: 15 Sep 2000 17:12:38 -0000
- Reply-To: chase at ece dot utexas dot edu
- Resent-Cc: gcc-prs at gcc dot gnu dot org, gcc-bugs at gcc dot gnu dot org, jason at gcc dot gnu dot org
- Resent-Reply-To: gcc-gnats@gcc.gnu.org, chase@ece.utexas.edu
>Number: 539
>Category: c++
>Synopsis: Incorrect type mismatch error reported for static members in templates
>Confidential: no
>Severity: non-critical
>Priority: medium
>Responsible: unassigned
>State: open
>Class: rejects-legal
>Submitter-Id: net
>Arrival-Date: Fri Sep 15 10:16:00 PDT 2000
>Closed-Date:
>Last-Modified:
>Originator: Craig Chase
>Release: gcc version 2.95.2 19991024 (release)
>Organization:
>Environment:
Cygwin 1.1.0 running on Windows 2000 professional (no service packs)
>Description:
A static constant used as the array size for a static array
results in GCC reporting a false type mismatch.
>How-To-Repeat:
This very simple/short program illustrates the problem.
>Fix:
I unfortunately do not have a fix, I do have a workaround.
The original declaration of the array can have an empty
size field. The final definition of the array can use
the correct size. For the program I attached, the work
around results in the following code.
template <typename T>
class Bug {
static const int size = 42;
static int array[]; // OK now.
};
template <typename T>
int Bug<T>::array[Bug<T>::size];
>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: application/x-unknown-content-type-CodeWarrior_cc; name="Bug.cc"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="Bug.cc"
dGVtcGxhdGUgPHR5cGVuYW1lIFQ+DQpjbGFzcyBCdWcgew0KICBzdGF0aWMgY29uc3QgaW50IHNp
emUgPSA0MjsNCiAgc3RhdGljIGludCBhcnJheVtdOw0KfTsNCg0KdGVtcGxhdGUgPHR5cGVuYW1l
IFQ+DQppbnQgQnVnPFQ+OjphcnJheVtCdWc8VD46OnNpemVdOw0K