Opened 13 years ago
Closed 10 years ago
#3869 closed Bugs (fixed)
Unconditional call to memset in value_initialized()
Reported by: | Aleksey Gurtovoy | Owned by: | niels_dekker |
---|---|---|---|
Milestone: | Boost 1.42.0 | Component: | utility |
Version: | Boost 1.41.0 | Severity: | Problem |
Keywords: | Cc: | agurtovoy@… |
Description
The call is there to workaround bugs in a few specific compilers, but is applied unconditionally, cannot be optimized away, and thus significantly limits applicability of the component in a library context.
See http://old.nabble.com/boost::mpl::for_each-and-value_initialized-td25246848.html for the full discussion.
Attachments (4)
Change History (14)
by , 13 years ago
Attachment: | config_compiler.patch added |
---|
comment:1 by , 13 years ago
Fernando (the author of value_init) mailed me that it's okay to him if I add an #ifdef to utility/value_init.hpp:
#ifdef BOOST_VALUE_INITIALIZATION_NEEDS_MEMSET std::memset(&x, 0, sizeof(x)); #endif
But therefor, this macro needs to be defined in <boost/config/compiler/...>, for the relevant compiler versions. Hereby I have attached my proposed additions to the trunk version of boost/config/compiler: config_compiler.patch Please check if it's okay.
comment:2 by , 13 years ago
The patch is OK as far as it goes, but we should have documentation and tests for each new macro, please see: http://www.boost.org/doc/libs/1_41_0/libs/config/doc/html/boost_config/guidelines_for_boost_authors.html#boost_config.guidelines_for_boost_authors.adding_new_defect_macros
Thanks, John.
comment:3 by , 13 years ago
Thanks, John. I read that there's a BOOST_NO_SOMETHING naming convention. So now I'm considering to name the macro BOOST_NO_PROPER_VALUE_INITIALIZATION_FOR_ALL_TYPES. (Instead of BOOST_VALUE_INITIALIZATION_NEEDS_MEMSET.) So that the unit test should show that compilers that have this macro defined do indeed do an improper value-initialization, for at least one type.
I'll have a closer look later...
comment:4 by , 13 years ago
Hereby I have just added a new patch for boost/config (to be applied to the trunk): https://svn.boost.org/trac/boost/attachment/ticket/3869/no_complete_value_initialization.patch It adds a new macro, BOOST_NO_COMPLETE_VALUE_INITIALIZATION, and includes documentation and tests. Please tell me what you think.
by , 13 years ago
Attachment: | no_complete_value_initialization.patch added |
---|
New proposed patch, adding BOOST_NO_COMPLETE_VALUE_INITIALIZATION. Replaces the old config_compiler.patch (Update: removed Boost.Test dependency, as suggested by John Maddock.)
by , 12 years ago
Attachment: | value_init_workaround.patch added |
---|
Made memset call conditional, based on BOOST_NO_COMPLETE_VALUE_INITIALIZATION
comment:5 by , 12 years ago
The value_init_workaround.patch I just attached should resolve this ticket. It assumes that the defect macro BOOST_NO_COMPLETE_VALUE_INITIALIZATION is defined for those compilers that need it (ticket #4080). Note that it adds an extra macro, BOOST_DETAIL_VALUE_INIT_WORKAROUND (defined as either 0 or 1), which controls whether the memset workaround is applied. This macro is merely intended as an implementation detail: I would like to have an extra test which toggles the value of the macro, in order to check if the workaround is both effective and necessary.
comment:6 by , 12 years ago
by , 12 years ago
Attachment: | value_init_workaround_test.cpp added |
---|
comment:7 by , 12 years ago
comment:8 by , 12 years ago
comment:10 by , 10 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
Closed, as suggested by Vicente (viboes).
Adds BOOST_VALUE_INITIALIZATION_NEEDS_MEMSET to trunk/boost/config/compiler