This is the mail archive of the gcc@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]
Other format: [Raw text]

Re: Invalid code in <limits>


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


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