A
Adrian
Hi all,
I am getting a warning compiling the following code using Borland C++
Builder 6, but I dont think I am doing anything wrong. When using g++ I
get no warnings at all with a g++ -Wall -ansi -pedantic.
Now I usually assume the compiler is correct but in this case I am not sure.
push 1 gives the warning the other 2 go through fine.
The warning text is:-
"C:\temp>bcc32 a.cpp
Borland C++ 5.6.4 for Win32 Copyright (c) 1993, 2002 Borland a.cpp:
Warning W8030 a.cpp 24: Temporary used for parameter '__x' in call to
'_STL::vector<A *,_STL::allocator<A *> >:ush_back(A * const &)' in
function main()
Turbo Incremental Link 5.66 Copyright (c) 1997-2002 Borland"
I cant see why a temporary is being created, what am I missing
TIA
--------------
#include <vector>
class A
{
public:
virtual ~A()=0;
private:
};
A::~A()
{
}
class BA : public A
{
public:
private:
};
int main()
{
std::vector<A *> fred;
fred.push_back(new BA()); // push 1 Gives warning
A *ptr=new BA();
fred.push_back(ptr); // push 2
fred.push_back(ptr=new BA()); // push 3
return 0;
}
I am getting a warning compiling the following code using Borland C++
Builder 6, but I dont think I am doing anything wrong. When using g++ I
get no warnings at all with a g++ -Wall -ansi -pedantic.
Now I usually assume the compiler is correct but in this case I am not sure.
push 1 gives the warning the other 2 go through fine.
The warning text is:-
"C:\temp>bcc32 a.cpp
Borland C++ 5.6.4 for Win32 Copyright (c) 1993, 2002 Borland a.cpp:
Warning W8030 a.cpp 24: Temporary used for parameter '__x' in call to
'_STL::vector<A *,_STL::allocator<A *> >:ush_back(A * const &)' in
function main()
Turbo Incremental Link 5.66 Copyright (c) 1997-2002 Borland"
I cant see why a temporary is being created, what am I missing
TIA
--------------
#include <vector>
class A
{
public:
virtual ~A()=0;
private:
};
A::~A()
{
}
class BA : public A
{
public:
private:
};
int main()
{
std::vector<A *> fred;
fred.push_back(new BA()); // push 1 Gives warning
A *ptr=new BA();
fred.push_back(ptr); // push 2
fred.push_back(ptr=new BA()); // push 3
return 0;
}