summaryrefslogtreecommitdiff
path: root/Source/Core/VideoCommon/ShaderGenCommon.h
diff options
context:
space:
mode:
authorcomex <comexk@gmail.com>2014-10-21 02:52:45 -0400
committercomex <comexk@gmail.com>2014-10-21 21:20:05 -0400
commit8492d04dfad2db79ccd0cd589a2eae2fabdc491a (patch)
treecdb65c3e3344a3ac595fb2bd654d165e5e481abf /Source/Core/VideoCommon/ShaderGenCommon.h
parent78deebd73281a3c4e451736d6e43bb49b7e7eaed (diff)
Use pointers instead of references in GetUidData to avoid the undefined behavior of *(T *)nullptr (ewwww)
Diffstat (limited to 'Source/Core/VideoCommon/ShaderGenCommon.h')
-rw-r--r--Source/Core/VideoCommon/ShaderGenCommon.h10
1 files changed, 5 insertions, 5 deletions
diff --git a/Source/Core/VideoCommon/ShaderGenCommon.h b/Source/Core/VideoCommon/ShaderGenCommon.h
index 527beeb725..0d2cb208c8 100644
--- a/Source/Core/VideoCommon/ShaderGenCommon.h
+++ b/Source/Core/VideoCommon/ShaderGenCommon.h
@@ -56,7 +56,7 @@ public:
* @warning since most child classes use the default implementation you shouldn't access this directly without adding precautions against nullptr access (e.g. via adding a dummy structure, cf. the vertex/pixel shader generators)
*/
template<class uid_data>
- uid_data& GetUidData() { return *(uid_data*)nullptr; }
+ uid_data* GetUidData() { return nullptr; }
};
/**
@@ -91,10 +91,10 @@ public:
return memcmp(this->values, obj.values, data.NumValues() * sizeof(*values)) < 0;
}
- template<class T>
- inline T& GetUidData() { return data; }
+ template<class uid_data2>
+ uid_data2* GetUidData() { return &data; }
+ const uid_data* GetUidData() const { return &data; }
- const uid_data& GetUidData() const { return data; }
size_t GetUidDataSize() const { return sizeof(values); }
private:
@@ -192,7 +192,7 @@ public:
file << "\n\nShader uid:\n";
for (unsigned int i = 0; i < new_uid.GetUidDataSize(); ++i)
{
- u32 value = ((u32*)&new_uid.GetUidData())[i];
+ u32 value = ((u32*)new_uid.GetUidData())[i];
if ((i % 4) == 0)
{
auto last_value = (i+3 < new_uid.GetUidDataSize()-1) ? i+3 : new_uid.GetUidDataSize();