[Boost-bugs] [Boost C++ Libraries] #1719: [addressof] Can't obtain the address of an instance of an anonymous struct

Subject: [Boost-bugs] [Boost C++ Libraries] #1719: [addressof] Can't obtain the address of an instance of an anonymous struct
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2008-03-26 18:12:10


#1719: [addressof] Can't obtain the address of an instance of an anonymous struct
-------------------------------------------------------+--------------------
 Reporter: Jean-François Bastien <jfbastien_at_[hidden]> | Type: Bugs
   Status: new | Milestone: Boost 1.36.0
Component: None | Version: Boost 1.34.1
 Severity: Problem | Keywords:
-------------------------------------------------------+--------------------
 I sent this to the Boost-users mailing list but got no feedback to
 validate the issue, but the bottom line is that there's a problem and I'd
 like addressof to offer a workaround if it's possible.


 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.

--
Ticket URL: <http://svn.boost.org/trac/boost/ticket/1719>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.


This archive was generated by hypermail 2.1.7 : 2017-02-16 18:49:57 UTC