[Lemon-commits] Alpar Juttner: Fix clang compilation issue (#634)

Lemon HG hg at lemon.cs.elte.hu
Thu Feb 25 10:24:26 CET 2021


details:   http://lemon.cs.elte.hu/hg/lemon/rev/a278d16bd2d0
changeset: 1433:a278d16bd2d0
user:      Alpar Juttner <alpar [at] cs.elte.hu>
date:      Wed Jul 29 14:56:10 2020 +0200
description:
	Fix clang compilation issue (#634)

diffstat:

 lemon/concepts/maps.h |  16 +++++++++-------
 1 files changed, 9 insertions(+), 7 deletions(-)

diffs (44 lines):

diff --git a/lemon/concepts/maps.h b/lemon/concepts/maps.h
--- a/lemon/concepts/maps.h
+++ b/lemon/concepts/maps.h
@@ -49,7 +49,12 @@
 
       /// Returns the value associated with the given key.
       Value operator[](const Key &) const {
-        return *(static_cast<Value *>(0)+1);
+        // return *(static_cast<Value *>(0));
+        // return *(static_cast<Value *>(0)+1);
+        // return *(static_cast<Value *>(sizeof(Value)));
+        // return *(reinterpret_cast<Value *>(0));
+        // return *(reinterpret_cast<Value *>(0)+1);
+        return *(reinterpret_cast<Value *>(sizeof(Value)));
       }
 
       template<typename _ReadMap>
@@ -131,8 +136,7 @@
 
       /// Returns the value associated with the given key.
       Value operator[](const Key &) const {
-        Value *r = 0;
-        return *r;
+        return *(reinterpret_cast<Value *>(sizeof(Value)));
       }
 
       /// Sets the value associated with the given key.
@@ -172,14 +176,12 @@
 
       /// Returns a reference to the value associated with the given key.
       Reference operator[](const Key &) {
-        Value *r = 0;
-        return *r;
+        return *(reinterpret_cast<Value *>(sizeof(Value)));
       }
 
       /// Returns a const reference to the value associated with the given key.
       ConstReference operator[](const Key &) const {
-        Value *r = 0;
-        return *r;
+        return *(reinterpret_cast<Value *>(sizeof(Value)));
       }
 
       /// Sets the value associated with the given key.


More information about the Lemon-commits mailing list