Bug 21373 - [4.0/4.1 Regression] Strange error message on reference to static const member initialized via cast
Summary: [4.0/4.1 Regression] Strange error message on reference to static const membe...
Status: RESOLVED DUPLICATE of bug 21165
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.0.0
: P2 normal
Target Milestone: 4.0.1
Assignee: Not yet assigned to anyone
URL:
Keywords: ice-checking, ice-on-valid-code, rejects-valid
Depends on:
Blocks:
 
Reported: 2005-05-03 21:39 UTC by Paul Koning
Modified: 2005-07-23 22:49 UTC (History)
1 user (show)

See Also:
Host: i686-pc-linux-gnu
Target: i686-pc-linux-gnu
Build: i686-pc-linux-gnu
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 Paul Koning 2005-05-03 21:39:20 UTC
Test program:

template <class T> class foo
{
public:
    static const unsigned long long max = (T)~0ULL;
    bool toobig (unsigned long long val) 
    {
        return val > max;
    }
};

Message:

test.cc: In member function ‘bool foo<T>::toobig(long long unsigned int)’:
test.cc:7: error: ‘T’ used where a ‘long long unsigned int’ was expected

The baffling part is that T doesn't occur anywhere in or near line 7.  It's
almost as if the initialization part of the static const member has been
textually substituted in line 7 -- but if it were that should still be legal... 

It works ok if I explicitly initialize the member outside the class definition
via specializations, which is tolerable given that only a small number of cases
of this template class are used.
Comment 1 Andrew Pinski 2005-05-03 21:44:04 UTC
Confirmed:
t.cc: In member function âbool foo<T>::toobig(long long unsigned int)â:
t.cc:7: internal compiler error: tree check: expected record_type or 
union_type or qual_union_type, have template_type_parm in lookup_conversions, 
at cp/search.c:2407
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://gcc.gnu.org/bugs.html> for instructions.


But this is a dup of bug 21165.

*** This bug has been marked as a duplicate of 21165 ***