<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/why-does-atan2-crash-the-zig-compiler-spir-v-only-of-course--elmyupbmi" -->

---
title: Why does atan2 crash the zig compiler? (SPIR-V only of...
description: A live coding stream transcript where the developer debugs two Zig compiler issues related to SPIR-V (GPU shader) code generation. The first bug involves...
canonical: https://daily.dev/posts/why-does-atan2-crash-the-zig-compiler-spir-v-only-of-course--elmyupbmi
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Why does atan2 crash the zig compiler? (SPIR-V only of course) | daily.dev
og:description: A live coding stream transcript where the developer debugs two Zig compiler issues related to SPIR-V (GPU shader) code generation. The first bug involves...
og:url: https://daily.dev/posts/why-does-atan2-crash-the-zig-compiler-spir-v-only-of-course--elmyupbmi
og:image: https://api.daily.dev/og/posts/eLmyUpbMi.png
og:image:alt: Why does atan2 crash the zig compiler? (SPIR-V only of course)
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Why does atan2 crash the zig compiler? (SPIR-V only of course)

**[sphaerophoria](https://daily.dev/sources/sphaerophoria)** · 131 min read · 0 upvotes · 0 comments

## Summary

A live coding stream transcript where the developer debugs two Zig compiler issues related to SPIR-V (GPU shader) code generation. The first bug involves `atan2` crashing the compiler due to `std.mem.doNotOptimizeAway` emitting a C long bitcast that is invalid on SPIR-V (which has no C interop). The fix involves special-casing the SPIR-V target to skip the register-size check. The second bug involves invalid SPIR-V being generated because slice types (pointer + length) are used in shader code, but SPIR-V does not support function-scope pointers. The developer traces through SPIR-V disassembly, Zig's AIR (Analyzed IR), and the compiler's semantic analysis to identify and fix both issues, with the goal of GPU-accelerating an SVG renderer.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://www.youtube.com/watch?v=n82P-F1LAJg>

---

Tags: [#gpu](https://daily.dev/tags/gpu), [#zig](https://daily.dev/tags/zig)

[View this post on daily.dev](https://daily.dev/posts/why-does-atan2-crash-the-zig-compiler-spir-v-only-of-course--elmyupbmi)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Why does atan2 crash the zig compiler? (SPIR-V only of course)","url":"https://daily.dev/posts/why-does-atan2-crash-the-zig-compiler-spir-v-only-of-course--elmyupbmi","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/why-does-atan2-crash-the-zig-compiler-spir-v-only-of-course--elmyupbmi"},"datePublished":"2026-07-12T23:11:30.411Z","dateModified":"2026-07-12T23:37:20.160Z","description":"A live coding stream transcript where the developer debugs two Zig compiler issues related to SPIR-V (GPU shader) code generation. The first bug involves...","image":"https://i.ytimg.com/vi/n82P-F1LAJg/sddefault.jpg","thumbnailUrl":"https://i.ytimg.com/vi/n82P-F1LAJg/sddefault.jpg","isAccessibleForFree":true,"articleSection":"sphaerophoria","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"sphaerophoria","logo":"https://media.daily.dev/image/upload/s--dgPUg2T7--/f_auto/v1728806109/logos/sphaerophoria","url":"https://daily.dev/sources/sphaerophoria"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/why-does-atan2-crash-the-zig-compiler-spir-v-only-of-course--elmyupbmi","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":0},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"gpu,zig","timeRequired":"PT131M","video":{"@type":"VideoObject","name":"Why does atan2 crash the zig compiler? (SPIR-V only of course)","description":"A live coding stream transcript where the developer debugs two Zig compiler issues related to SPIR-V (GPU shader) code generation. The first bug involves...","thumbnailUrl":"https://i.ytimg.com/vi/n82P-F1LAJg/sddefault.jpg","uploadDate":"2026-07-12T23:11:30.411Z","duration":"PT131M","url":"https://api.daily.dev/r/eLmyUpbMi","embedUrl":"https://www.youtube.com/embed/n82P-F1LAJg"}}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"sphaerophoria","item":"https://daily.dev/sources/sphaerophoria"},{"@type":"ListItem","position":3,"name":"Why does atan2 crash the zig compiler? (SPIR-V only of course)"}]}
```

