This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

c++/539: Incorrect type mismatch error reported for static members in templates



>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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]