Boost logo

Boost :

Subject: [boost] operator+ and void*: differences between g++ and msvc
From: Frédéric Bron (frederic.bron_at_[hidden])
Date: 2011-06-16 15:32:33


Hi,

I am trying to perform an exhaustive testing of the operator traits. I
came to the following issue: this code yields an error with msvc and
only a warning with g++:

int lhs=0;
void* rhs=0;
lhs + rhs;

* msvc (Visual C++ 2010 Express):
error C2036: 'void *' : unknown size
warning C4552: '+' : operator has no effect; expected operator with side-effect

* g++ (4.5.3):
warning: pointer of type 'void *' used in arithmetic

The standard says:
"Either both operands shall have arithmetic or enumeration type, or
one operand shall be a
pointer to a completely defined object type and the other shall have
integral or enumeration type."

So it seems to me that an error should be issued by g++. What is your
understanding of the standard?
If this is so, do you suggest me to file a bug to g++?

Frédéric


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk