Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: Berlin, bcc32 compiler bug?


This question is answered. Helpful answers available: 2. Correct answers available: 1.


Permlink Replies: 11 - Last Post: May 25, 2016 11:24 PM Last Post By: Vladimir Ulchenko
Johnny Willemsen

Posts: 55
Registered: 2/27/02
Berlin, bcc32 compiler bug?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: May 25, 2016 12:55 AM
Hi,

The code below does compile with bcc64 but fails with bcc32, a compiler bug? The error we get:
Error E2045 .\Compiler_Features_37_Test.cpp 25: Destructor name must match the class name in function ~my_map<unsigned int,Bar *>::my_map()

Johnny

#include <utility>

template <typename key, typename value>
class my_map
{
public:
~my_map ();
typedef key key_type;
typedef value data_type;
typedef std::pair<key, value> value_type;
size_t capacity_;
value_type* nodes_;
};

template <typename key, typename value>
my_map<key, value>::~my_map ()
{
for (size_t i = 0; i != capacity_; ++i) {
(nodes_ + i)->~value_type ();
}
}

class Bar
{
public:
Bar () {}
~Bar () {}
};

int _tmain(int argc, _TCHAR* argv[])
{
my_map <size_t, Bar*> foo;
return 0;
}

Arkady Semylio

Posts: 87
Registered: 9/18/15
Re: Berlin, bcc32 compiler bug?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: May 25, 2016 5:40 AM   in response to: Johnny Willemsen in response to: Johnny Willemsen
(nodes_ + i)->~value_type ();

Uhm... not sure if std::pair has a defined destructor... neither I'm sure
if it's possible to call a default dtor in older C++.
Johnny Willemsen

Posts: 55
Registered: 2/27/02
Re: Berlin, bcc32 compiler bug?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: May 25, 2016 5:43 AM   in response to: Arkady Semylio in response to: Arkady Semylio
Arkady Semylio wrote:
(nodes_ + i)->~value_type ();

Uhm... not sure if std::pair has a defined destructor... neither I'm sure
if it's possible to call a default dtor in older C++.

We build this code with msvc7 and newer, gcc 3.x and newer, HP compilers, no problems at all.
Arkady Semylio

Posts: 87
Registered: 9/18/15
Re: Berlin, bcc32 compiler bug?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: May 25, 2016 8:57 AM   in response to: Johnny Willemsen in response to: Johnny Willemsen
Johnny Willemsen wrote:
Arkady Semylio wrote:
(nodes_ + i)->~value_type ();

Uhm... not sure if std::pair has a defined destructor... neither I'm sure
if it's possible to call a default dtor in older C++.

We build this code with msvc7 and newer, gcc 3.x and newer, HP compilers, no problems at all.

So it's definitively a bug. Have you tried with the clang/BCC32C (see the appropriate switch in the configurations)?
Johnny Willemsen

Posts: 55
Registered: 2/27/02
Re: Berlin, bcc32 compiler bug?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: May 25, 2016 11:13 AM   in response to: Arkady Semylio in response to: Arkady Semylio
So it's definitively a bug. Have you tried with the clang/BCC32C (see the appropriate switch in the configurations)?

bcc32c compiles this without problems, but we can't switch to bcc32c because that would mean we have first todo a major porting effort for our infrastructure and I doubt we can get it working, bcc64 is already a major problem due to its bugs.
Vladimir Ulchenko

Posts: 248
Registered: 1/12/00
Re: Berlin, bcc32 compiler bug?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: May 25, 2016 8:07 AM   in response to: Arkady Semylio in response to: Arkady Semylio
On Wed, 25 May 2016 05:40:23 -0700, Arkady Semylio <> wrote:

if it's possible to call a default dtor in older C++.

perhaps you confused it with C++ standard forbidding to take the address of a destructor at 12.4.2?

--
Vladimir Ulchenko aka vavan
Arkady Semylio

Posts: 87
Registered: 9/18/15
Re: Berlin, bcc32 compiler bug?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: May 25, 2016 8:51 AM   in response to: Vladimir Ulchenko in response to: Vladimir Ulchenko
Vladimir Ulchenko wrote:
On Wed, 25 May 2016 05:40:23 -0700, Arkady Semylio <> wrote:

if it's possible to call a default dtor in older C++.

perhaps you confused it with C++ standard forbidding to take the address of a destructor at 12.4.2?

Maybe.
Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: Berlin, bcc32 compiler bug?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: May 25, 2016 10:00 AM   in response to: Johnny Willemsen in response to: Johnny Willemsen
Johnny wrote:

The code below does compile with bcc64 but fails with bcc32,
a compiler bug?

I'm curious why you are rolling your own map class instead of using std::map?

--
Remy Lebeau (TeamB)
Johnny Willemsen

Posts: 55
Registered: 2/27/02
Re: Berlin, bcc32 compiler bug?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: May 25, 2016 11:14 AM   in response to: Remy Lebeau (Te... in response to: Remy Lebeau (Te...
Remy Lebeau (TeamB) wrote:
Johnny wrote:

The code below does compile with bcc64 but fails with bcc32,
a compiler bug?

I'm curious why you are rolling your own map class instead of using std::map?

Just a lot of old code which are using its own map API (it is all from before std::map was there), not an easy task, so we just keep this own map

Johnny
Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: Berlin, bcc32 compiler bug?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: May 25, 2016 11:32 AM   in response to: Johnny Willemsen in response to: Johnny Willemsen
Johnny wrote:

Just a lot of old code which are using its own map API (it is all from
before std::map was there), not an easy task, so we just keep this
own map

Don't you think it is time to switch to std::map by now? You could simply
use std::map inside of your my_map class so you keep the same interface,
but let std::map do all of the actual work for you:

#include <map>
 
template <typename key, typename value>
class my_map
{
public:
    typedef std::map<key, value>::key_type key_type;
    typedef std::map<key, value>::mapped_type data_type;
    typedef std::map<key, value>::value_type value_type;
    std::map<key, value> nodes_;
};
 
class Bar
{
public:
    Bar () {}
    ~Bar () {}
};
 
int _tmain(int argc, _TCHAR* argv[])
{
    my_map <size_t, Bar*> foo;
    return 0;
}


Or simplier:

#include <map>
 
template <typename key, typename value>
class my_map : public std::map<key, value>
{
public:
    typedef std::map<key, value>::mapped_type data_type;
};
 
class Bar
{
public:
    Bar () {}
    ~Bar () {}
};
 
int _tmain(int argc, _TCHAR* argv[])
{
    my_map <size_t, Bar*> foo;
    return 0;
}


--
Remy Lebeau (TeamB)
Johnny Willemsen

Posts: 55
Registered: 2/27/02
Re: Berlin, bcc32 compiler bug?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: May 25, 2016 11:38 AM   in response to: Remy Lebeau (Te... in response to: Remy Lebeau (Te...
Remy Lebeau (TeamB) wrote:
Johnny wrote:

Just a lot of old code which are using its own map API (it is all from
before std::map was there), not an easy task, so we just keep this
own map

Don't you think it is time to switch to std::map by now? You could simply
use std::map inside of your my_map class so you keep the same interface,
but let std::map do all of the actual work for you:

Could be, but this is just the first place where I hit this compiler bug, could be that there are more, at this moment we are looking for a confirmation of the bug and see if there is a workaround without rewriting a lot of other code (replacing it is not a small effort).

Johnny
Vladimir Ulchenko

Posts: 248
Registered: 1/12/00
Re: Berlin, bcc32 compiler bug?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: May 25, 2016 11:24 PM   in response to: Remy Lebeau (Te... in response to: Remy Lebeau (Te...
On Wed, 25 May 2016 11:32:29 -0700, Remy Lebeau (TeamB) <no dot spam at no dot spam dot com> wrote:

class my_map : public std::map<key, value>

beware that std containers are not meant to be inherited (no virtual destructor etc.) though

--
Vladimir Ulchenko aka vavan
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02