LocationQuery: fix a segfault due to ill guided conversion path
This commit is contained in:
parent
1406aa5532
commit
16abe82cde
3 changed files with 64 additions and 17 deletions
|
|
@ -71,7 +71,7 @@
|
|||
//#include <boost/noncopyable.hpp>
|
||||
//#include <string>
|
||||
//#include <vector>
|
||||
//#include <utility>
|
||||
#include <utility>
|
||||
//#include <memory>
|
||||
|
||||
|
||||
|
|
@ -102,11 +102,12 @@ namespace interact {
|
|||
class GenNodeLocationQuery
|
||||
: public LocationQuery
|
||||
{
|
||||
Rec const& tree_;
|
||||
Rec tree_;
|
||||
|
||||
public:
|
||||
GenNodeLocationQuery(Rec const& backingStructure)
|
||||
: tree_(backingStructure)
|
||||
template<class REC>
|
||||
GenNodeLocationQuery(REC&& backingStructure)
|
||||
: tree_(std::forward<REC>(backingStructure))
|
||||
{ }
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -33,30 +33,31 @@
|
|||
**
|
||||
** ## design decisions
|
||||
** The Record type is shaped from its intended use: It serves to symbolically represent
|
||||
** \em objects in the "external tree description". Here, \em objects means objects for
|
||||
** real, i.e. with types, fields and an enclosed scope. But \em external means that we
|
||||
** do not work on these objects right here, we only represent them, for later referral,
|
||||
** \em symbolically.
|
||||
** _objects_ in the "external tree description". Here, "objects" means objects _for real_,
|
||||
** i.e. with types, fields and an enclosed scope. But \em external means that we do not work
|
||||
** on these objects right here, we only represent them, for later referral, _symbolically_.
|
||||
**
|
||||
** \par rationale
|
||||
** The underlying theme and motivation of this design is negative: we do not want
|
||||
** to build _yet another object system_. The object model of C++ is deemed adequate.
|
||||
**
|
||||
** This leads to the following decisions
|
||||
** - the Record entity is itself an object and thus has an inner side, privately.
|
||||
** The entrails of the Record can be reworked and tuned for performance
|
||||
** - yet the Record has an external appearance, which makes it look flat and passive.
|
||||
** This is to say, a Record has no visible functionality.
|
||||
** - the parts or \em realms within this symbolic representation are distinguished
|
||||
** - the parts or _realms_ within this symbolic representation are distinguished
|
||||
** by convention solely
|
||||
**
|
||||
** * metadata is very limited and boils down to a type attribute known by name
|
||||
** * children (scope contents) can be recognised by \em not bearing a name
|
||||
** * children (scope contents) can be recognised by _not_ bearing a name
|
||||
**
|
||||
** Record entities are meant to be immutable. The proper way to alter a Record is
|
||||
** to apply a \link tree-diff.hpp diff \endlink. Yet for the \em implementation
|
||||
** of this diff handling, a Record::Mutator is provided, to allow controlled
|
||||
** partial re-building of a given data element.
|
||||
**
|
||||
** \par rationale
|
||||
** The underlying theme of this design is negative, dialectical: we do not want to
|
||||
** build yet another object system. The object model of C++ is deemed adequate.
|
||||
** to apply a [diff](\ref tree-diff.hpp). Yet for the _implementation_ of this
|
||||
** diff handling, a Record::Mutator is provided, to allow controlled partial
|
||||
** re-building of a given data element. Moreover, especially for Record<GenNode>,
|
||||
** this mutator can be used for a DSL-style compact notation of a complete
|
||||
** "object tree" -- a feature intended for writing unit tests.
|
||||
**
|
||||
** @remarks
|
||||
** - the implementation is focused on the intended primary use case,
|
||||
|
|
@ -279,6 +280,14 @@ namespace diff{
|
|||
* copy-initialise (or convert) from the given Mutator instance.
|
||||
* @remarks need to code this explicitly, otherwise Record's
|
||||
* build-from sequence templated ctor would kick in.
|
||||
* @warning beware of initialiser lists. Record has a dedicated
|
||||
* ctor to accept an initialiser list of GenNode elements,
|
||||
* and GenNode's ctor is deliberately _not explicit,_ to ease
|
||||
* building argument lists wrapped in GenNodes. When writing
|
||||
* initialisation expressions inline, the compiler might pick
|
||||
* the conversion path through initialiser list, which means
|
||||
* the contents of the Mutator end up wrapped into a GenNode,
|
||||
* which in turn becomes the only child of the new Record.
|
||||
*/
|
||||
Record (Mutator const& mut)
|
||||
: Record((Record const&) mut)
|
||||
|
|
|
|||
|
|
@ -4577,6 +4577,43 @@
|
|||
</node>
|
||||
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1506984645747" ID="ID_517262443" MODIFIED="1508625810426" TEXT="verify_backingQuery">
|
||||
<icon BUILTIN="pencil"/>
|
||||
<node CREATED="1508809610790" ID="ID_1860790851" MODIFIED="1508809620175" TEXT="Builder-Syntax war falsch"/>
|
||||
<node CREATED="1508809620762" ID="ID_236111511" MODIFIED="1508809630860" TEXT="muß die Attribute-Collection nutzen"/>
|
||||
<node CREATED="1508809631448" ID="ID_956153388" MODIFIED="1508809644482" TEXT="Builder wohl noch nie für diesen Fall verwendet"/>
|
||||
<node CREATED="1508809645470" ID="ID_1846245702" MODIFIED="1508809656617" TEXT="erlaube Move-Initialisierung"/>
|
||||
<node CREATED="1508809657253" ID="ID_108704029" MODIFIED="1508809659905" TEXT="Segfault">
|
||||
<node CREATED="1508809662036" ID="ID_1522595538" MODIFIED="1508809674479" TEXT="sehe zwar die drei Window-Elemente"/>
|
||||
<node CREATED="1508809674994" ID="ID_1781272984" MODIFIED="1508809683317" TEXT="aber die ID-Strings sind komisch">
|
||||
<node CREATED="1508809684338" ID="ID_1268163778" MODIFIED="1508809688341" TEXT="erster String ist """/>
|
||||
<node CREATED="1508809688881" ID="ID_1836564528" MODIFIED="1508809700115" TEXT="zweiter String hat richtigen Anfang..."/>
|
||||
<node CREATED="1508809700919" ID="ID_733585050" MODIFIED="1508809716393" TEXT="aber wird mit nachfolgendem Müll angezeigt"/>
|
||||
<node CREATED="1508809719165" ID="ID_1506398379" MODIFIED="1509064569893" TEXT="Segfault beim Initialisieren des Ergebnisses für extractKey"/>
|
||||
</node>
|
||||
<node CREATED="1508809741418" ID="ID_1013369537" MODIFIED="1509070755705" TEXT="Verdacht: irgendwo move mit dangling storage?"/>
|
||||
<node CREATED="1509070756935" ID="ID_1331980374" MODIFIED="1509070861495" TEXT="nein! Nur eine Referenz vom Temporary">
|
||||
<richcontent TYPE="NOTE"><html>
|
||||
<head>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
<p>
|
||||
...merke
|
||||
</p>
|
||||
<p>
|
||||
die Spezialbehandlung für const& gilt nur, wenn wir direkt auch diesen Typ nehmen.
|
||||
</p>
|
||||
<p>
|
||||
Im vorliegenden fall wird aber der conversion-Operator aufgerufen, um den Initializser zu erzeugen.
|
||||
</p>
|
||||
<p>
|
||||
Daher denkt der Compiler, er kann das Ursprungsobjekt jezt wergwerfen.
|
||||
</p>
|
||||
</body>
|
||||
</html>
|
||||
</richcontent>
|
||||
<icon BUILTIN="ksmiletris"/>
|
||||
</node>
|
||||
</node>
|
||||
</node>
|
||||
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1506984645748" ID="ID_1254044275" MODIFIED="1506984664457" TEXT="verify_queryAnchor">
|
||||
<icon BUILTIN="flag-yellow"/>
|
||||
|
|
|
|||
Loading…
Reference in a new issue