# Diving deep into anonymous struct literals

**URL:** <https://ziggit.dev/t/diving-deep-into-anonymous-struct-literals/2931>\
**Category:** Explain\
**Tags:** language\
**Created:** [January 19, 2024, 9:29pm UTC](https://ziggit.dev/t/diving-deep-into-anonymous-struct-literals/2931 "2024-01-19T21:29:49Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![bnl1](https://ziggit.dev/user_avatar/ziggit.dev/bnl1/32/1464_2.png) [@bnl1](https://ziggit.dev/u/bnl1)\
**Post date:** [January 19, 2024, 10:58pm UTC](https://ziggit.dev/t/diving-deep-into-anonymous-struct-literals/2931/3 "2024-01-19T22:58:30Z")

</div>

I believe @matklad is right here. Notice the output of the program:

```zig
    const cn: isize = 42; // c1 == c2
    var vn: isize = 123; // v1 != v2
    @compileLog(&.{ .a = &cn, .b = &cn });
    @compileLog(&.{ .a = &cn, .b = &cn });
    @compileLog(&.{ .a = &vn, .b = &vn });
    @compileLog(&.{ .a = &vn, .b = &vn });
    @compileLog(&.{ .a = &cn, .b = &vn });
    @compileLog(&.{ .a = &cn, .b = &vn });

```

is

```zig
literals.zig:19:5: error: found compile log statement
    @compileLog(&.{ .a = &cn, .b = &cn });
    ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Compile Log Output:
@as(*const struct{comptime a: *const isize = 42, comptime b: *const isize = 42}, .{.a = 42, .b = 42})
@as(*const struct{comptime a: *const isize = 42, comptime b: *const isize = 42}, .{.a = 42, .b = 42})
@as(*const struct{a: *isize, b: *isize}, [runtime value])
@as(*const struct{a: *isize, b: *isize}, [runtime value])
@as(*const struct{comptime a: *const isize = 42, b: *isize}, [runtime value])
@as(*const struct{comptime a: *const isize = 42, b: *isize}, [runtime value])

```

From what I know, comptime values are always interned. This is required from the correct semantics of things like generic functions.

---

_[View the full topic](https://ziggit.dev/t/diving-deep-into-anonymous-struct-literals/2931)._
