This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Invalid code in <limits>
- From: Phil Edwards <phil at jaj dot com>
- To: Mark Mitchell <mark at codesourcery dot com>
- Cc: Gabriel Dos Reis <gdr at integrable-solutions dot net>, "gcc at gcc dot gnu dot org" <gcc at gcc dot gnu dot org>, "rth at redhat dot com" <rth at redhat dot com>
- Date: Wed, 29 Jan 2003 14:40:20 -0500
- Subject: Re: Invalid code in <limits>
- References: <20030129190606.GA25112@disaster.jaj.com> <67070000.1043867780@warlock.codesourcery.com>
On Wed, Jan 29, 2003 at 11:16:20AM -0800, Mark Mitchell wrote:
> --On Wednesday, January 29, 2003 02:06:06 PM -0500 Phil Edwards
> <phil@jaj.com> wrote:
>
> >
> > a_certain_template < __builtin_foo(x) == __a_value >
>
> This is different, actually -- an integral constant-expression is not
> required there. The expression must be constant, but it's gramatically
> an assignment-expression, and the standard is unclear on what constraints
> are supposed to be applied, exactly.
Ah. *ahem* I suggest "exactly the constraints we're applying now,"
whatever those happen to be. :-)
> > template <typename T>
> > struct is_foo
> > {
> > static const bool value = __builtin_is_foo(T);
> > };
>
> Out of curiousity, how are you dealing with this? In other words, how
> is "is_POD<int>" implemented? (I'd probably do something more like
> static_cast in that case, but I'm curious what you ended up with. I
> haven't thought about it long enough to have too much confidence.)
Shortly I'll be posting something; yesterday a slightly different approach
occurred to me (in the middle of getting the cast on my leg changed;
heaven only knows how my mind works). I'm dealing with a hard drive crash
at work, but after a bit of rewriting it'll be up for discussion on the
cxx-reflection branch.
Basically, there's a sizeof/alignof/typeof-ish keyword that returns all
available reflection information (similar to 'typeid' in that respect).
To make things easier, various __builtin_xxx functions are added which
take the reflection information and extract the more commonly-used pieces.
is_POD happens to be one of the 3 or 4 traits which haven't been done yet.
> template <int I>
> void f(S<I + 3 + 4>);
>
> is guaranteed by the ABI to be mangled as "I + 3 + 4", not with "I + 7".
> (The ISO standard explicitly says that these might or might not be the
> same template; the ABI says that they are not.)
As Johnny Carson might say, I did not know that.
> Gaby's proposed that:
>
> template <int I>
> void f(S<I + __builtin_1()>);
>
> and:
>
> template <int I>
> void f(S<I + 1>);
>
> are the same template, if __builtin_1 is a builtin that always returns 1.
>
> If you've created new builtins of some kind that can be used like this,
> you have to worry about this too. :-)
Hmmm. Dunno yet. Using these new ones like that certainly wouldn't
be useful.
Phil
--
I would therefore like to posit that computing's central challenge, viz. "How
not to make a mess of it," has /not/ been met.
- Edsger Dijkstra, 1930-2002