July 07, 2006
On Boost mail-list Gabriel dos Reis wrote that

friend T;

(where T is template parameter) was voted
in standard. Likely by virtue of bug this is already
supported by DMC:

---------------------
template<typename T>
void foo()
{
  friend T; // <<== not valid in C++98, likely valid in C++0x
}

int main()
{
  return 0;
}
------------------------

I also tried "auto", a very likely addition to C++0x
but it is not yet there.

/Pavel


July 07, 2006
One of Boost tests (is_abstract_test for Type Traits)
causes compiler crash:

nbytes = 65736, ph_maxsize = 65520
Internal error: ph 1848
--- errorlevel 1

http://www.digitalmars.com/~arjan/boost/status/dmc8492/cs-win32-links.html#type_traits-is_abstract_test-dmc-stlport


The test is huge (and this is likely source of
the problem - individual is_abstract<> works OK).

Perhaps some fix could be found without
creating minimalistic single file with no includes.
If not, I may attempt to generate such file.

/Pavel


July 10, 2006
Snippet, extracted from Eric Niebler's MAX() "final solution"
(posted on Boost mail-list today). Works on Comeau,
reportedly works on GCC.
http://article.gmane.org/gmane.comp.lib.boost.devel/145250


----------------------------------------
template<typename Type>
Type* encode_type(Type &) { return 0; }


template<typename Ret, typename Left, typename Right>
struct max_impl
{
    max_impl(Left &left, Right &right)
      : left_(left)
      , right_(right)
    {}

    operator Ret &() const
    {
        return this->left_ < this->right_ ? this->right_ : this->left_;
    }

private:
    Left &left_;
    Right &right_;
};


template<typename Ret, typename Left, typename Right>
max_impl<Ret, Left, Right>
max_fun(Left &left, Right &right, Ret *)
{
    return max_impl<Ret, Left, Right>(left, right);
}


#define MAX(a,b)\
    (true\
         ? max_fun((a), (b), \
                   (true? 0 : encode_type(true? (a) : (b))))\
         : (true? (a) : (b)))


int main()
{
    double x = MAX(1, 2.0);
    return 0;
}
------------------------------------


The code looks like using a ?: trick from BOOST_FOREACH
so it the error could be relevalant to Boost.


/Pavel


July 11, 2006
Hi all

I ran this code on this version of g++:
g++ (GCC) 4.0.2 20050901 (prerelease) (SUSE Linux)
Copyright (C) 2005 Free Software Foundation, Inc.

I get the following:

query.cpp: In function ?int main()?:
query.cpp:41: error: invalid initialization of non-const reference of type ?double&? from a temporary of type ?double?
query.cpp:2: error: in passing argument 1 of ?Type* encode_type(Type&) [with Type = double]?

I hope this helps

John

Pavel Vozenilek wrote:
> Snippet, extracted from Eric Niebler's MAX() "final solution"
> (posted on Boost mail-list today). Works on Comeau,
> reportedly works on GCC.
> http://article.gmane.org/gmane.comp.lib.boost.devel/145250
> 
> 
> ----------------------------------------
> template<typename Type>
> Type* encode_type(Type &) { return 0; }
> 
> 
> template<typename Ret, typename Left, typename Right>
> struct max_impl
> {
>     max_impl(Left &left, Right &right)
>       : left_(left)
>       , right_(right)
>     {}
> 
>     operator Ret &() const
>     {
>         return this->left_ < this->right_ ? this->right_ : this->left_;
>     }
> 
> private:
>     Left &left_;
>     Right &right_;
> };
> 
> 
> template<typename Ret, typename Left, typename Right>
> max_impl<Ret, Left, Right>
> max_fun(Left &left, Right &right, Ret *)
> {
>     return max_impl<Ret, Left, Right>(left, right);
> }
> 
> 
> #define MAX(a,b)\
>     (true\
>          ? max_fun((a), (b), \
>                    (true? 0 : encode_type(true? (a) : (b))))\
>          : (true? (a) : (b)))
> 
> 
> int main()
> {
>     double x = MAX(1, 2.0);
>     return 0;
> }
> ------------------------------------
> 
> 
> The code looks like using a ?: trick from BOOST_FOREACH
> so it the error could be relevalant to Boost.
> 
> 
> /Pavel
> 
> 

July 12, 2006
Calling user defined overloaded operator delete fails,
DMC treats it as a cast:

------------------------------------------------
struct aux {};

struct aaa
{
    void* operator new(unsigned n, aux) { return 0; }
    void operator delete(void* p, aux) {}
};

int main()
{
    aux x;
    aaa* a = new (x) aaa;
    // a->~aaa();
    operator delete (x) a;
    return 0;
}
------------------------------------------------

This is example presented by Steve Clamage in: http://groups.google.com/group/comp.std.c++/msg/663146bd8f253361



I also noticed that DMC doesn't warn when
overloaded member operator delete() does not exists
and corresp[onding overloaded operator new() exists.
I vainly tried to find out what is Standard's take on this.

I.e. this compiles w/o warnings:

--------------------------------------------
struct aux {};

struct aaa
{
    void* operator new(unsigned n, aux) { return 0; }
    void operator delete(void* p) {}
};

int main()
{
    aux x;
    aaa* a = new (x) aaa;
    delete a;
    return 0;
}
--------------------------------------------

For the same code Intel C++ issues quite informative warnings:

warning #873: function "aaa::operator new" has no corresponding operator
delete (to be called if an exception is thrown during initialization of an
allocated object)
      void* operator new(unsigned n, aux) { return 0; }



This problem doesn't come from Boost but
from a OO in-memory database which uses this
technique.

/Pavel


1 2
Next ›   Last »