authorgravatar for thatlemon@gmail.comLemonBoy <thatlemon@gmail.com> 2020-12-09 20:47:56+01:00
committergravatar for thatlemon@gmail.comLemonBoy <thatlemon@gmail.com> 2020-12-10 09:23:48+01:00
log584451140843f8e1524f3cebf0ca3ab580685b3d
tree5f2f1f61760a27de838d3aa9c61bc6de1a66b67c
parentef7db9717ec6b08a7ef7ed043819bf4855e0a828

std: prevent instantiation of atomic.Int with non-integral types


1 files changed, 3 insertions(+), 0 deletions(-)

lib/std/atomic/int.zig+3
...@@ -10,6 +10,9 @@ const testing = std.testing;...@@ -10,6 +10,9 @@ const testing = std.testing;
1010
11/// Thread-safe, lock-free integer11/// Thread-safe, lock-free integer
12pub fn Int(comptime T: type) type {12pub fn Int(comptime T: type) type {
13 if (!std.meta.trait.isIntegral(T))
14 @compileError("Expected integral type, got '" ++ @typeName(T) ++ "'");
15
13 return extern struct {16 return extern struct {
14 unprotected_value: T,17 unprotected_value: T,
1518