
Thomas Klimpel wrote:
Why don't you simply believe Hartmut when he tells you that everything is fine?
It's not fine, it's UB. Pure luck if it works on some (even most) platforms. I don't play dice.
OK, the dangerous looking code is as follows:
grammar( start_type const& start , std::string const& name_ = "unnamed-grammar") => : proto::extends<terminal, base_type>(terminal::make(
start.alias())) , name_(name_) {}
I completely agree that the constructor of start has not yet been called, because grammar is the base class of your object. However, the memory for start is already there, and the "this" pointer of start already has the "correct" value. Now, all "start.alias()" does is to return a wrapped reference to "*this" of the start object. Are you sure that this doesn't work?
Only compiler knows if would it actually work. I've seen enough strange compiler behaviors to reject such dangerous code. If the question is whether to switch from the conforming implementation to the non-conforming, my answer is "not to switch". Don't get me wrong, I'm not an enemy to Spirit2. I simply reported a problem with the new implementation interface. The developers may take it into account to improve the library, don't you think?