public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/19919] New: [regression 3.3/3.4.4.0]
@ 2005-02-12 16:24 kent at sas dot com
  2005-02-12 16:27 ` [Bug c++/19919] [regression 3.3/3.4/4.0] kent at sas dot com
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: kent at sas dot com @ 2005-02-12 16:24 UTC (permalink / raw)
  To: gcc-bugs

this snippet from firebird "vulcan" project.  it compiles with gcc 3.2

sorry, i'm still learning what i can cut out of the sample and still have it be
valid C++


GNU C++ version 3.4.2 20041017 (Red Hat 3.4.2-6.fc3) (i386-redhat-linux)
        compiled by GNU C version 3.4.2 20041017 (Red Hat 3.4.2-6.fc3).

host> g++ a.cpp

a.cpp: In static member function `static const Key& BePlusTree<Value, Key,
Allocator, KeyOfValue, Cmp, LeafCount, NodeCount>::NodeList::generate(void*,
void*)':a.cpp:114: error: expected primary-expression before ')' token
a.cpp:114: error: expected `)' before "item"
a.cpp:115: error: expected `)' before ';' token


-------- a.cpp ---------

#define NULL ((void*)0)
typedef long long size_t;


// Very fast static array of simple types
template <typename T, int Capacity>
  class Vector
  {
  public:
    Vector() : count(0) {}
    T& operator[](int index) { return data[index]; }
    T* begin() { return data; }
    T* end() { return data + count; }

  protected:
    int count;
    T data[Capacity];
  };


// Template to convert value to index directly
template <typename T>
  class DefaultKeyValue
  {
  public:
    static const T& generate(void* sender, const T& Item) { return Item; }
  };

// Template for default value comparsion
template <typename T>
  class DefaultComparator
  {
  public:
    static bool greaterThan(const T& i1, const T& i2) { return i1 > i2; }
  };


// Fast sorted array of simple objects
// It is used for B+ tree nodes lower, but can still be used by itself
template <typename Value, int Capacity, typename Key = Value,
  typename KeyOfValue = DefaultKeyValue<Value>,
  typename Cmp = DefaultComparator<Key> >
  class SortedVector : public Vector<Value, Capacity>
  {
  public:
    SortedVector() : Vector<Value, Capacity>() {}
  };




  class MallocAllocator {
  public:
    void *allocate(size_t size) {return NULL;}
    void deallocate(void *p) { }
  };



  template <typename Value,
    typename Key = Value, typename Allocator = MallocAllocator,
    typename KeyOfValue = DefaultKeyValue<Value>,
    typename Cmp = DefaultComparator<Key>,
    int LeafCount = 100,
    int NodeCount = 100 >
    class BePlusTree {
    public:
      BePlusTree(Allocator *_pool) : pool(_pool), level(0), defaultAccessor(this)
        {
          root = new (_pool->allocate(sizeof(ItemList))) ItemList();
        };

      ~BePlusTree() { }

      bool add(const Value& item) { return defaultAccessor.add(item); }


    private:
      BePlusTree(Allocator *_pool, void *rootPage) :    pool(_pool), level(0),
        root(new(rootPage) ItemList()), defaultAccessor(this) {}

      class NodeList;

    public:
      class ItemList : public SortedVector<Value,LeafCount,Key,KeyOfValue,Cmp>
      {
      public:
        NodeList *parent;
        ItemList *next, *prev;
        // Adds newly created item to doubly-linked list
        ItemList(ItemList *items) : parent(NULL) { }
        ItemList() : parent(NULL), next(NULL), prev(NULL) {};

        friend class BePlusTree;
        friend class BePlusTree::NodeList;
      };

    private:
      class NodeList : public SortedVector<void*,NodeCount,Key,NodeList,Cmp>
      {
      public:
        NodeList(NodeList *items) : parent(NULL) {}
        NodeList() : parent(NULL), next(NULL), prev(NULL) {}

        int level;
        NodeList *parent;
        NodeList *next, *prev;
        static const Key& generate(void *sender, void *item)
          {
            for (int lev = ((NodeList *)sender)->level; lev > 0; lev--)
            item = *((NodeList *)item)->begin();
            return KeyOfValue::generate(item,
                                        *((BePlusTree::ItemList *)item)->begin()
                                       );
          }
      };

    public:
      class Accessor
      {
      public:
        Accessor(BePlusTree* _tree) : tree(_tree), curr(NULL), curPos(0) {}
                Value& current() const { return (*curr)[curPos]; }
      public:
        BePlusTree* tree;
        ItemList *curr;
        int curPos;
      };

    public:
      Allocator *pool;
      int level;
      void *root;
      Accessor defaultAccessor;


      friend class MemoryPool;
      friend class NodeList;
      friend class Accessor;
    };

-- 
           Summary: [regression 3.3/3.4.4.0]
           Product: gcc
           Version: 3.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: kent at sas dot com
                CC: gcc-bugs at gcc dot gnu dot org
  GCC host triplet: i386-redhat-linux


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19919


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug c++/19919] [regression 3.3/3.4/4.0]
  2005-02-12 16:24 [Bug c++/19919] New: [regression 3.3/3.4.4.0] kent at sas dot com
@ 2005-02-12 16:27 ` kent at sas dot com
  2005-02-12 16:33 ` pinskia at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: kent at sas dot com @ 2005-02-12 16:27 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From kent at sas dot com  2005-02-12 03:50 -------
sorry, next time i'll add a.cpp as an attachment.  still getting the hang of this.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |diagnostic
      Known to fail|                            |3.3
      Known to work|                            |3.2
            Summary|[regression 3.3/3.4.4.0]    |[regression 3.3/3.4/4.0]


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19919


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug c++/19919] [regression 3.3/3.4/4.0]
  2005-02-12 16:24 [Bug c++/19919] New: [regression 3.3/3.4.4.0] kent at sas dot com
  2005-02-12 16:27 ` [Bug c++/19919] [regression 3.3/3.4/4.0] kent at sas dot com
@ 2005-02-12 16:33 ` pinskia at gcc dot gnu dot org
  2005-02-12 21:00 ` kent at sas dot com
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-02-12 16:33 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-02-12 05:59 -------
are sure that this is valid c++?

-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19919


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug c++/19919] [regression 3.3/3.4/4.0]
  2005-02-12 16:24 [Bug c++/19919] New: [regression 3.3/3.4.4.0] kent at sas dot com
  2005-02-12 16:27 ` [Bug c++/19919] [regression 3.3/3.4/4.0] kent at sas dot com
  2005-02-12 16:33 ` pinskia at gcc dot gnu dot org
@ 2005-02-12 21:00 ` kent at sas dot com
  2005-02-13  6:21 ` pinskia at gcc dot gnu dot org
  2005-02-14 19:46 ` kent at sas dot com
  4 siblings, 0 replies; 6+ messages in thread
From: kent at sas dot com @ 2005-02-12 21:00 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From kent at sas dot com  2005-02-12 15:37 -------
i'm personally not sure; there is a test harness in the vulcan tree that i'll
extract and submit as an attachment.

the code in question has compiled and run on at least MSVC7, sun forte as well
as GCC 3.2.x; so in that sense "i'm sure it works on other compilers"


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19919


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug c++/19919] [regression 3.3/3.4/4.0]
  2005-02-12 16:24 [Bug c++/19919] New: [regression 3.3/3.4.4.0] kent at sas dot com
                   ` (2 preceding siblings ...)
  2005-02-12 21:00 ` kent at sas dot com
@ 2005-02-13  6:21 ` pinskia at gcc dot gnu dot org
  2005-02-14 19:46 ` kent at sas dot com
  4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-02-13  6:21 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-02-12 22:22 -------
This code is invalid and here is why:
BePlusTree::ItemList is a dependent name so it needs a typenam keyword in front of it to say that this 
name is a type.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |INVALID


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19919


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug c++/19919] [regression 3.3/3.4/4.0]
  2005-02-12 16:24 [Bug c++/19919] New: [regression 3.3/3.4.4.0] kent at sas dot com
                   ` (3 preceding siblings ...)
  2005-02-13  6:21 ` pinskia at gcc dot gnu dot org
@ 2005-02-14 19:46 ` kent at sas dot com
  4 siblings, 0 replies; 6+ messages in thread
From: kent at sas dot com @ 2005-02-14 19:46 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From kent at sas dot com  2005-02-14 15:03 -------
got it now, thanks, and sorry for the interuption.  i've made some good progress
over the weekend on getting this to compile - i appreciate you getting me over
the hurdle. paul.

-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19919


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2005-02-14 15:03 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-02-12 16:24 [Bug c++/19919] New: [regression 3.3/3.4.4.0] kent at sas dot com
2005-02-12 16:27 ` [Bug c++/19919] [regression 3.3/3.4/4.0] kent at sas dot com
2005-02-12 16:33 ` pinskia at gcc dot gnu dot org
2005-02-12 21:00 ` kent at sas dot com
2005-02-13  6:21 ` pinskia at gcc dot gnu dot org
2005-02-14 19:46 ` kent at sas dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).