[cmake-developers] Storage reallocation inside std::vector causing memory problem when using variable_watch
Yves Frederix
yves.frederix+cmake at gmail.com
Wed Mar 23 06:26:08 EDT 2016
Hi Brad,
> Thanks, I missed the problem for the `return def` line. However, I
> think both places are a problem. I think it is simplest to just
> re-lookup the variable value at the end of the variable watch if()
> block.
Please find a patch in attachment. In order to reduce the number of
double value lookups (8378 for my simple case), I also changed the
interface of VariableAccessed to return a bool (resulting in 3 double
lookups). The patch was tested based onto 3.4.1 and I can confirm that
it fixes the problem.
>
>> 3. Define a move constructor in the cmDefinitions class. Probably that
>> is not an option as IIRC CMake uses C++98. I did, however, check this
>> solution locally, compiling CMake using VS2012 and can verify that it
>> fixes the problem.
>
> CMake actually does build as C++11 or C++14 by default with some
> compilers, but we must retain the ability to build and work as C++98.
> One could conditionally define a move constructor simply to improve
> efficiency when we do build as C++11. The above fix would still be
> needed though.
Makes sense. I'm not sure, however, how to test if the compiler
supports move construction. A link on stackoverflow suggests to use
something like "201103L <= __cplusplus". Unfortunately this does not
work for, e.g., VS2012 as it still defines __cplusplus as 199711L.
What would be a good way of checking this?
Regards,
Yves
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Relookup-variable-value-in-case-it-has-an-associated.patch
Type: application/octet-stream
Size: 3097 bytes
Desc: not available
URL: <http://public.kitware.com/pipermail/cmake-developers/attachments/20160323/83b6f777/attachment.obj>
More information about the cmake-developers
mailing list