MantisBT - CMake | |||||
View Issue Details | |||||
ID | Project | Category | View Status | Date Submitted | Last Update |
0013786 | CMake | CMake | public | 2012-12-12 05:01 | 2016-06-10 14:31 |
Reporter | Andreas Mohr | ||||
Assigned To | Kitware Robot | ||||
Priority | high | Severity | major | Reproducibility | always |
Status | closed | Resolution | moved | ||
Platform | PC | OS | Linux / Windows | OS Version | RHEL5 / 7 |
Product Version | CMake 2.8.10.2 | ||||
Target Version | Fixed in Version | ||||
Summary | 0013786: function() set(PARENT_SCOPE) buggy: very surprising warn-uninitialized inconsistency for (non-)empty values | ||||
Description | I tried to get all my code free of issues, thus I enabled --warn-uninitialized. I was very surprised to find that initialization state of a function result (PARENT_SCOPE) variable is being very negatively influenced by the value of the passed variable being empty vs. non-empty, as can be gathered from the sample below warning about result_empty yet properly *not* warning about result_non_empty. This should emphatically _not_ be the case - a result variable should *always* get properly initialized (instantiated) in outer scope, no fr****n' matter which value it may happen to get assigned. And it's not a "this variable already exists in outer scope" vs. "does not exist --> problem" issue: when assigning non-empty values the outer-scope variable *does* get created, yet not for empty ones --> BUG. Note that pre-initializing the result var to "" prior to invoking the function does successfully silence the initialization warning. And note that doing this initialization with a non-empty value and subsequently calling the function *does* let the function reset the variable to empty - IOW the variable *does* get assigned by the function in *this* case - just not if it didn't exist previously! Happening on both Win7 2.8.10.2 and RHEL5 2.8.8..... Severity major and prio high since it's a foundation-shattering inconsistency ;) Given this bug it's impossible to get one's code warning-free (when making use of clean result-use-only variable getter functions which happen to return empty values in certain conditions). A mere "not succeeding in getting the code warning-free" is a rather benign concern - some actively disrupting bug scenarios due to this issue might be conceivable, too. Thanks! | ||||
Steps To Reproduce | cmake_minimum_required(VERSION 2.8) function(getter _result) set(result_ "${desired_result}") set(${_result} "${result_}" PARENT_SCOPE) endfunction(getter _result) #set(result_empty "bye, cruel world") # <---- toggle this! set(desired_result "") getter(result_empty) set(desired_result "non-empty") getter(result_non_empty) message("result_empty ${result_empty}, result_non_empty ${result_non_empty}.") | ||||
Additional Information | $ cmake --warn-uninitialized . Warn about uninitialized values. CMake Warning (dev) at /home/amoh/privat/cmake_tests/bug_function_result_uninitialized_warning/CMakeLists.txt:14: uninitialized variable 'result_empty' This warning is for project developers. Use -Wno-dev to suppress it. result_empty , result_non_empty non-empty. -- Configuring done -- Generating done | ||||
Tags | No tags attached. | ||||
Relationships | |||||
Attached Files | |||||
Issue History | |||||
Date Modified | Username | Field | Change | ||
2012-12-12 05:01 | Andreas Mohr | New Issue | |||
2012-12-14 03:46 | Andreas Mohr | Note Added: 0031887 | |||
2013-08-30 08:03 | Mark Abraham | Note Added: 0033765 | |||
2013-08-30 08:04 | Mark Abraham | Note Edited: 0033765 | bug_revision_view_page.php?bugnote_id=33765#r1249 | ||
2013-08-30 08:07 | Mark Abraham | Note Edited: 0033765 | bug_revision_view_page.php?bugnote_id=33765#r1250 | ||
2013-08-30 08:16 | Mark Abraham | Note Edited: 0033765 | bug_revision_view_page.php?bugnote_id=33765#r1251 | ||
2016-06-10 14:28 | Kitware Robot | Note Added: 0042169 | |||
2016-06-10 14:28 | Kitware Robot | Status | new => resolved | ||
2016-06-10 14:28 | Kitware Robot | Resolution | open => moved | ||
2016-06-10 14:28 | Kitware Robot | Assigned To | => Kitware Robot | ||
2016-06-10 14:31 | Kitware Robot | Status | resolved => closed |
Notes | |||||
|
|||||
|
|
||||
|
|||||
|
|
||||
|
|||||
|
|