ICE

  • Thread starter Vladimir Nesterovsky
  • Start date
V

Vladimir Nesterovsky

Hello all,

can someone confirm internal compiler error in a following code (both VS2005
and VS2003):

#include <iostream>

class worker_base
{
public:
virtual int execute() const = 0;
};

class worker_impl: public worker_base
{
private:
int value;
public:
worker_impl(const worker_impl &other): value(other.value)
{
std::cout << "copy constructor, value = " << value << std::endl;
}

worker_impl(int value): value(value)
{
std::cout << "constructor, value = " << value << std::endl;
}

// If in VC 2003 to omit destructor, compilation succeeds, always.
~worker_impl()
{
std::cout << "destructor, value = " << value << std::endl;
}

virtual int execute() const { return value; }
};

struct worker_ref
{
const worker_base &worker;

operator const worker_base & () const { return worker; }
};

int func(const worker_ref args[], int size)
{
int result = 0;

for(int i = 0; i < size; i++)
{
const worker_base &worker = args;

result += worker.execute();
}

return result;
}

template<int size>
inline int func(const worker_ref (&args)[size])
{
return func(args, size);
}

int main(int argc, char* argv[])
{

#if 1 // ICE

const worker_ref args[] =
{
worker_impl(1), worker_impl(2), worker_impl(3)
};

#else // ICE

const worker_base &w1 = worker_impl(1);
const worker_base &w2 = worker_impl(2);

const worker_ref args[] =
{
w1, w2, worker_impl(3)
};

#endif // ICE

int result = func(args);

std::cout << result << std::endl;

return 0;
}


Thanks in advance.
 
A

Andras Tantos

Hello all,
can someone confirm internal compiler error in a following code (both
VS2005
and VS2003):

....

Thank you for reporing this issue. We will investigate the bug and its scope
to make a decision when and how will we address the problem.

Regards,
Andras Tantos
Visual C++ Team
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top