-
Type:
Bug
-
Resolution: Done
-
Priority:
Major - P3
-
Affects Version/s: None
-
Component/s: Internal Code
-
None
-
Fully Compatible
-
ALL
-
-
Platform 3 05/15/15
-
None
-
None
-
None
-
None
-
None
-
None
-
None
Clang 3.6 added a new warning for the use of typeid with glvalue's. I.e. in situations where the argument is an expression and it would have to be evaluated with possible side effects.
Error:
scons: Building targets ...
Compiling build/linux2/x86_64/cc_clang/cxx_clang++/mongo/db/storage/in_memory/in_memory_recovery_unit.o
src/mongo/db/storage/in_memory/in_memory_recovery_unit.cpp:71:70: error: expression with side
effects will be evaluated despite being used as an operand to 'typeid'
[-Werror,-Wpotentially-evaluated-expression]
LOG(2) << "CUSTOM ROLLBACK " << demangleName(typeid(*change));
^
1 error generated.
Compiling build/linux2/x86_64/cc_clang/cxx_clang++/mongo/db/storage/mmap_v1/dur_recovery_unit.o
src/mongo/db/storage/mmap_v1/dur_recovery_unit.cpp:181:69: error: expression with side effects
will be evaluated despite being used as an operand to 'typeid'
[-Werror,-Wpotentially-evaluated-expression]
LOG(2) << "CUSTOM ROLLBACK " << demangleName(typeid(*_changes[i]));
This appeared in:
http://lists.cs.uiuc.edu/pipermail/cfe-commits/Week-of-Mon-20141215/120369.html
------------
We have two options moving forward:
Add a suppression:
--- a/SConstruct
+++ b/SConstruct
@@ -1333,6 +1333,9 @@ def doConfigure(myenv):
# we explicitly disable it here.
AddToCCFLAGSIfSupported(myenv, "-Wno-missing-braces")
+ # Ignore potentially evaluated expressions
+ AddToCCFLAGSIfSupported(myenv, "-Wno-potentially-evaluated-expression")
+
# Check if we need to disable null-conversion warnings
if myenv.ToolchainIs('clang'):
def CheckNullConversion(context):
Change two points in the code to clean this up (the below patch is sufficient for me)
--- a/src/mongo/db/storage/in_memory/in_memory_recovery_unit.cpp
+++ b/src/mongo/db/storage/in_memory/in_memory_recovery_unit.cpp
@@ -67,7 +67,7 @@ namespace mongo {
try {
for (Changes::reverse_iterator it = _changes.rbegin(), end = _changes.rend();
it != end; ++it) {
- ChangePtr change = *it;
+ Change* change = it->get();
LOG(2) << "CUSTOM ROLLBACK " << demangleName(typeid(*change));
change->rollback();
}
--- a/src/mongo/db/storage/mmap_v1/dur_recovery_unit.cpp
+++ b/src/mongo/db/storage/mmap_v1/dur_recovery_unit.cpp
@@ -178,7 +178,8 @@ namespace mongo {
try {
for (int i = _changes.size() - 1; i >= changesRollbackTo; i--) {
- LOG(2) << "CUSTOM ROLLBACK " << demangleName(typeid(*_changes[i]));
+ Change* change = _changes[i];
+ LOG(2) << "CUSTOM ROLLBACK " << demangleName(typeid(*change));
_changes[i]->rollback();
}
Basically just do whatever side effecty stuff we need to before the call to typeid.
- is duplicated by
-
SERVER-19486 Can't install MongoDB on El Capitan
-
- Closed
-