Hacker News

Top stories

Live mirror
30 storiesupdated just nowView source snapshot
  1. AI Has No Wisdom and Neither Will You(alexn.org)
    171comments
  2. Can gzip be a language model?(nathan.rs)
    83comments
  3. MiMo v2.6(xiaomi.com)
    437comments
  4. AMD's random number generator can't generate a 0?(flatassembler.net)
    92comments
  5. Spymarks, Not Watermarks(brand.io)
    129comments
  6. 9 Ads per Minute: FIFA Cup 26 – "the price of the beautiful game"(bristol.ac.uk)
    135comments
  7. I said no and Apple said yes(dbushell.com)
    309comments
  8. Attention is all you have(alicegg.tech)
    270comments
  9. Transformers Explained Visually(poloclub.github.io)
    75comments
  10. What Sun got wrong(dtrace.org)
    357comments
  11. A font that reads what you wrote(rohanadwankar.github.io)
    22comments
  12. MiMo-v2.6-Pro: Intelligence, Performance and Price Analysis(artificialanalysis.ai)
    42comments
  13. Type Punning in C and C++(pwkf.org)
    12comments
  14. I don't want to read what you didn't write(colinbreck.com)
    332comments
  15. Verda (Finland) raises $189M in Series B(verda.com)
    18comments
  16. Line Scan Photos from MUNI Heritage Weekend in San Francisco(lawrence.lu)
    3comments
  17. AI coding has made CI a bottleneck, so we reworked ours to keep up(linear.app)
    321comments
  18. Engineering Memory: On learning to memorize first 100 digits of pi (2024)(gregorygundersen.com)
    20comments
  19. Divide by depth for instant 3D(gabrieloc.com)
    32comments
  20. NASA’s Mars Sample Return mission is dead(science.org)
    340comments
  21. Looking forward to Git 2.56 – and 3.0(lwn.net)
    84comments
  22. What It's Like to Work in One of America's Data Centers(wsj.com)
    15comments
  23. World Wide Words(worldwidewords.org)
    2comments
  24. A build graph that rolls dice(fzakaria.com)
    2comments
  25. The Advisory Group on Mathematics and Artificial Intelligence(terrytao.wordpress.com)
    75comments
  26. Claude Status – Elevated errors for multiple models(claude.com)
    98comments
  27. HERMES radio enables voice and data communication over vast distances(ieee.org)
    64comments
  28. Socrates vs. the Written Word (2011)(wondermark.com)
    37comments
  29. Python Workers are now generally available(cloudflare.com)
    39comments
  30. How do traffic signals work? (2019)(practical.engineering)
    68comments

Type Punning in C and C++

32 pointsby 2h agoblog.pwkf.org
13 comments
1h agoHN ↗

Does reinterpret_cast works in c++ for this?

1h agoHN ↗

The C vs C++ distinction here is genuinely treacherous

What's so genuine about this?

1h agoHN ↗

Despite the fact they're two different languages, people are often taught as though it's basically just a subset relationship and then they carry this through into the actual software they write.

Because neither of these are memory safe languages, you are required to ensure you've made no mistakes or else anything might happen.

55m agoHN ↗

It continues with

and most blog posts on the topic get it wrong.

This smells like Claudism/LLMish.

46m agoHN ↗

The example included below "Why C and C++ Differ" is UB in both C and C++ (and says nothing about "why" C & C++ differ). The article isn't overall wrong but that bit is just...

(Feels a bit like LLM junk, but honestly not sure.)

39m agoHN ↗

A pointer cast worked fine at -O0 and silently broke at -O2.

Feels like LLM to me. I looked at some of the rest of the article and... pretty much certain now.

42m agoHN ↗

Is it necessary to use the lowest possible font weight?

33m agoHN ↗

I just watched video[0] that argues if you can consteval something, then it must be free of UB, which seems compelling, at least for these lower level helpers.

Unfortunately, it seems memcpy is not constexpr, so cannot be used like this, but std::bit_cast actually works[1] as constexpr, so I think in C++ that would now be the most preferred use. It won't allow the union either.

[0] https://www.youtube.com/watch?v=-LAXqqqX274 [1] https://godbolt.org/z/xGzjTMGvv

19m agoHN ↗

The conclusion is simply wrong. `union` should not be used for type-punning in C++, or in C code which might be compiled by a C++ compiler.

I can't downvote posts yet, but if you have the ability, consider it. This is clearly LLM slop without human review.