Subject: Re: [Boost-bugs] [Boost C++ Libraries] #8157: Access violation of const objects
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2013-02-26 00:32:44
#8157: Access violation of const objects
---------------------------------------------------+------------------------
Reporter: MichaÅ KÄdrzyÅski <kedrzu@â¦> | Owner: ramey
Type: Bugs | Status: new
Milestone: To Be Determined | Component: serialization
Version: Boost 1.52.0 | Severity: Problem
Resolution: | Keywords: const
---------------------------------------------------+------------------------
Comment (by MichaÅ KÄdrzyÅski <kedrzu@â¦>):
This is indeed possible, however very nasty. Consider this piece of code:
{{{
class foo {
public:
void bar(int i) const {
std::cout << i << std::endl;
}
};
int main() {
// create an instance
foo f;
// create a pointer to the function
void (foo::*func)(int) = reinterpret_cast<void
(foo::*)(int)>(&foo::bar);
// call it with non const object
(f.*func)(1);
(f.*func)(2);
(f.*func)(3);
(f.*func)(4);
return 0;
}
}}}
Const function have been cast to non constant, which is probably not very
elegant, but if proper static assertions would be provide, I think it
won't be so bad.
-- Ticket URL: <https://svn.boost.org/trac/boost/ticket/8157#comment:4> 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:50:12 UTC