shader_ir: Address feedback to avoid UB in bit casting
This commit is contained in:
		| @@ -4,6 +4,7 @@ | |||||||
|  |  | ||||||
| #pragma once | #pragma once | ||||||
|  |  | ||||||
|  | #include <cstring> | ||||||
| #include <map> | #include <map> | ||||||
| #include <set> | #include <set> | ||||||
| #include <string> | #include <string> | ||||||
| @@ -606,8 +607,9 @@ private: | |||||||
|     } |     } | ||||||
|     /// Creates a f32 immediate |     /// Creates a f32 immediate | ||||||
|     Node Immediate(f32 value) { |     Node Immediate(f32 value) { | ||||||
|         // TODO(Rodrigo): Replace this with bit_cast when C++20 releases |         u32 integral; | ||||||
|         return Immediate(*reinterpret_cast<const u32*>(&value)); |         std::memcpy(&integral, &value, sizeof(u32)); | ||||||
|  |         return Immediate(integral); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     /// Generates a node for a passed register. |     /// Generates a node for a passed register. | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 ReinUsesLisp
					ReinUsesLisp