|
Boost Users : |
From: Jean-Francois Bastien (jfbastien_at_[hidden])
Date: 2008-03-20 15:57:30
We're running into an issue with addressof as described at:
https://savannah.cern.ch/bugs/?33071
Basically this fails under GCC 3.4.4 as well as GCC 4.3:
struct // NoName
{
} noName;
void * fail()
{
return addressof(noName);
}
The error message is "no matching function for call to
`addressof(<anonymous struct>&)'".
MSVC 2005 SP1 compiles and runs this with no problem.
The problem seems to be that GCC can't deduce the templated type because
the struct is anonymous. I'm not sure whether this is because it's
non-standard behavior that MSVC accepts and GCC doesn't or because GCC
has a bug.
Either way it would be nice if addressof had a workaround for the
"broken" GCC versions, but I'm not sure what the best workaround would
be. Axel suggested in the above link to C-style cast to char &, but this
causes a problem in the (unlikely) event where operator char &() is
declared in the anonymous struct. We could use template magic to see if
operator char &() is declared, but I'm not very comfortable with such a
huge workaround.
If the discussion points towards a bug in GCC I'll file a bug report
with them, but either way addressof isn't working with GCC 3.4.4 and 4.3
(at least), and it would be nice of Boost to offer a workaround.
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net