EPICS Home

Experimental Physics and Industrial Control System


 
2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  <20172018  2019  2020  2021  2022  2023  2024  Index 2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  <20172018  2019  2020  2021  2022  2023  2024 
<== Date ==> <== Thread ==>

Subject: Re: EPICS 7.0.1-pre1 (pdbsingle.cpp)
From: Dirk Zimoch <[email protected]>
To: <[email protected]>
Date: Thu, 23 Nov 2017 12:03:47 +0100


On 23.11.2017 11:19, Dirk Zimoch wrote:
Clang 3.4.2 gives an interesting hint with its warnings. It seems that
this call creates a temporary, for which of course a copy is needed. If
you wanted to detect accidental copies, this is such a case.

I have analyzed the code a bit.

The message was:
"C++98 requires an accessible copy constructor for class 'FieldName' when binding a reference to a temporary"

The line in question is:
pvif(channel->pv->builder->attach(channel->pv->chan, pvf, FieldName()))

This is the constructor call of pvif in the constructor of PDBSinglePut.
It is true, that a temporary is used here. FieldName() creates an object that falls out of scope immediately after the attach() call.

The compiler cannot know what builder->attach() will do with with the temporary. It has to expect the worst, which is to keep a reference to the temporary FieldName object after the attach() call has returned. Since this would then reference an invalid object.

So maybe the compiler rather implicitly creates a copy of which builder->attach can keep a reference, like this: attach(new FieldName(FieldName()))

I need to check the C++ standard to see what the documented behavior is in such a case.


Replies:
Re: EPICS 7.0.1-pre1 (pdbsingle.cpp) Dirk Zimoch
References:
EPICS 7.0.1-pre1 Andrew Johnson
Re: EPICS 7.0.1-pre1 Dirk Zimoch
Re: EPICS 7.0.1-pre1 (pdbsingle.cpp) Michael Davidsaver
Re: EPICS 7.0.1-pre1 (pdbsingle.cpp) Dirk Zimoch

Navigate by Date:
Prev: Re: EPICS 7.0.1-pre1 (pdbsingle.cpp) Dirk Zimoch
Next: Re: EPICS 7.0.1-pre1 (pdbsingle.cpp) Dirk Zimoch
Index: 2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  <20172018  2019  2020  2021  2022  2023  2024 
Navigate by Thread:
Prev: Re: EPICS 7.0.1-pre1 (pdbsingle.cpp) Dirk Zimoch
Next: Re: EPICS 7.0.1-pre1 (pdbsingle.cpp) Dirk Zimoch
Index: 2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  <20172018  2019  2020  2021  2022  2023  2024