We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent a983760 commit 6e4dc82Copy full SHA for 6e4dc82
3 files changed
vlib/sync/channels.c.v
@@ -59,7 +59,7 @@ pub:
59
}
60
61
pub fn new_channel[T](n u32) &Channel {
62
- st := sizeof(T)
+ st := if sizeof(T) > 0 { sizeof(T) } else { 1 }
63
if isreftype(T) {
64
return new_channel_st(n, st)
65
} else {
vlib/sync/empty_struct_chan_init_test.v
@@ -0,0 +1,8 @@
1
+struct User {
2
+}
3
+
4
+fn test_empty_struct_chan_init() {
5
+ user_ch := chan User{cap: 10}
6
+ println(user_ch)
7
+ assert true
8
vlib/v/gen/c/cgen.v
@@ -3095,7 +3095,9 @@ fn (mut g Gen) expr(node_ ast.Expr) {
3095
3096
g.write(', sizeof(')
3097
g.write(elem_typ_str)
3098
- g.write('))')
+ g.write(')>0 ? sizeof(')
3099
+ g.write(elem_typ_str)
3100
+ g.write(') : 1)')
3101
3102
ast.CharLiteral {
3103
g.char_literal(node)
0 commit comments