www.digitalmars.com         C & C++   DMDScript  

c++.beta - [bug 8.49.2]

reply "Pavel Vozenilek" <pavel_vozenilek yahoo.co.uk> writes:
This code snippet works under Intel 7.0 and Comeau
Online, fails to compile under the latest beta.
It is trimmed down dynamic_bitset example from Boost.


-----------------------------------------------------------------
namespace boost {
    namespace detail {

    template <typename T>
    struct dynamic_bitset_allowed_block_type {
        enum { value = T(-1) > 0 }; // ensure T has no sign <<<=== here it 
fails
    };

    } // namespace detail

// static assert support
template <bool x> struct STATIC_ASSERTION_FAILURE;
template <> struct STATIC_ASSERTION_FAILURE<true> { enum { value = 1 }; };
template<int x> struct static_assert_test{};



template<typename Block = unsigned long>
class dynamic_bitset
{
    typedef ::boost::static_assert_test
    <
        sizeof(::boost::STATIC_ASSERTION_FAILURE< (bool) (
            detail::dynamic_bitset_allowed_block_type<Block>::value ) >)
    >
    boost_static_assert_typedef_999;

public:
    dynamic_bitset(unsigned num_bits, unsigned long value = 0) {}
};

} // namespace boost

int main()
{
    boost::dynamic_bitset<> x(5);
    return 0;
}
--------------------------------------------------------------




It fails with some "invalid syntax" message:
       x.cpp(11) : Error: '}' expected



Trying to find the minimal test I was able to provoke
invalid generation of code (resulting in system dialog
whether I wish to send error report to Redmond :).


I do not know what value could such finding has,
it is not minimal and requires using Boost headers.


/Pavel
Jul 06 2006
next sibling parent "Pavel Vozenilek" <pavel_vozenilek yahoo.co.uk> writes:
This tiny snippet works on Intel and Comeau online
(and should just everywhere):

---------------------------------
#include <new>

int main()
{
  char* ch = new (std::nothrow) char[1];
  return 0;
}
-------------------------------------

It comes from Boost.Pool.
The error emitted is:
   x.cpp(8) : Error: no match for function '?_P(unsigned ,const 
std::nothrow_t)'


/Pavel
Jul 06 2006
prev sibling next sibling parent "Pavel Vozenilek" <pavel_vozenilek yahoo.co.uk> writes:
Following snippet compiles in Intel and online Comeau.
DMC fails with error:
   x.cpp(26) : Error: 'tuple' is already defined

---------------------------------------
struct nil_t {};

template <typename A = nil_t>
struct tuple;

template <typename DerivedT>
struct tuple_base {};

template <>
struct tuple<> : public tuple_base<tuple<> > {};

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

This was extracted from Boost.Spirit (the parser library).

/Pavel
Jul 06 2006
prev sibling next sibling parent "Pavel Vozenilek" <pavel_vozenilek yahoo.co.uk> writes:
This code snippet compiles in Comeau and Intel.

-----------------------------------------
template<class T>
class bbb
{
public:
    explicit bbb(T val)
        : n((val.max)()-(val.min)()) //<<<== here it fails, notice the 
parenthesis
    {
    }


private:
    T::result_type n;
};


struct ccc
{
    typedef int result_type;
    int min() { return 0; }
    int max() { return 0; }
};


int main()
{
    ccc c;
    bbb<ccc> b(c);
    return 0;
}
--------------------------------------------------

In DMC it returns:
  x.cpp(6) : Error: type mismatch
  Had: bbb<ccc >
  and: ccc
  x.cpp(7) : Error: need explicit cast to convert
  from: bbb<ccc >
  to  : int

The problematic part are the parenthesis around
"max.val" call as in (max.val)().

If the parenthesis are removed it compiles. I guess they are
there in order to switch off any ADL lookup.

The code is trimmed down snippet from failing Boost.Random.

/Pavel
Jul 06 2006
prev sibling next sibling parent reply Walter Bright <newshound digitalmars.com> writes:
Thanks for the new reports.

Is the 8.49.2 beta at least getting further than 8.49.1?
Jul 06 2006
parent "Pavel Vozenilek" <pavel_vozenilek yahoo.co.uk> writes:
"Walter Bright" wrote:

 Is the 8.49.2 beta at least getting further than 8.49.1?

Yes, some Boost tests do work now. The Boost official bug report still uses the very old compiler - I was told they had switched but nothing's visible so far. I also tried to compile the STLport 5.10 said to support DMC: they have bugs in makefile. /Pavel
Jul 07 2006
prev sibling next sibling parent "Pavel Vozenilek" <pavel_vozenilek yahoo.co.uk> writes:
This code compiles on Intel and Comeau.
It is trimmed down problem with Boost.Operators
and Boost.Serialization.

-------------------------------------------
template <class T, class U>
struct aaa
{
    friend bool operator==(const U& y, const T& x) { return x == y; }
};

struct bbb {};

struct ccc {};

int main()
{
    aaa<bbb, ccc> a;
    return 0;
}
--------------------------------------------

/Pavel
Jul 07 2006
prev sibling next sibling parent "Pavel Vozenilek" <pavel_vozenilek yahoo.co.uk> writes:
A bug courtesy of Boost.CRC. Intel + Comeau work here.

---------------------------------------------
template< int T>
struct uint_t;

template
<
    unsigned Bits,
    typename uint_t<Bits>::fast U

template <unsigned Bits> void foo(aaa<Bits, 1> *p); int main() { return 0; } -------------------------------------------- /Pavel
Jul 07 2006
prev sibling next sibling parent "Pavel Vozenilek" <pavel_vozenilek yahoo.co.uk> writes:
With code:

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

no warning is given
although there's clear mistake.

Comeau and BCB do emit error ("unreachable"), Intel doesn't.

/Pavel
Jul 07 2006
prev sibling next sibling parent "Pavel Vozenilek" <pavel_vozenilek yahoo.co.uk> writes:
Works on Intel, Comeau:

-----------------------------------
template< typename T, unsigned sz >
inline T* range_begin( T (&array)[sz] )
{
    return array;
}

template< class T >
inline void begin( T& r )
{
    range_begin( r );
}

int main()
{
    const int sz = 9;
    int           my_array[sz]  = { 1,2,3,4,5,6,7,8,9 };

    begin( my_array );
    return 0;
}
----------------------------------------

I am not really sure what is the problem, possibly
something with different rules for array decay on
templates and non-templates.

This is trimmed down problem from Boost.Range.



Btw, compilation of Boost.Range
(and Boost.String Algorithms that use Range)
is veeery slow with DMC.

The Intel 7.0 does compile some tests visibly faster.

/Pavel
Jul 07 2006
prev sibling next sibling parent "Pavel Vozenilek" <pavel_vozenilek yahoo.co.uk> writes:
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
Jul 07 2006
prev sibling next sibling parent "Pavel Vozenilek" <pavel_vozenilek yahoo.co.uk> writes:
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
Jul 07 2006
prev sibling next sibling parent reply "Pavel Vozenilek" <pavel_vozenilek yahoo.co.uk> writes:
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
Jul 10 2006
parent user domain.invalid writes:
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
 
 

Jul 11 2006
prev sibling parent "Pavel Vozenilek" <pavel_vozenilek yahoo.co.uk> writes:
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
Jul 12 2006