Hacker News

Top stories

Live mirror
30 storiesupdated just nowView source snapshot
  1. AI Has No Wisdom and Neither Will You(alexn.org)
    191comments
  2. Can gzip be a language model?(nathan.rs)
    85comments
  3. MiMo v2.6(xiaomi.com)
    437comments
  4. Spymarks, Not Watermarks(brand.io)
    130comments
  5. AMD's random number generator can't generate a 0?(flatassembler.net)
    95comments
  6. I said no and Apple said yes(dbushell.com)
    316comments
  7. 9 Ads per Minute: FIFA Cup 26 – "the price of the beautiful game"(bristol.ac.uk)
    141comments
  8. Type Punning in C and C++(pwkf.org)
    13comments
  9. Attention is all you have(alicegg.tech)
    271comments
  10. Transformers Explained Visually(poloclub.github.io)
    77comments
  11. What Sun got wrong(dtrace.org)
    357comments
  12. A font that reads what you wrote(rohanadwankar.github.io)
    22comments
  13. MiMo-v2.6-Pro: Intelligence, Performance and Price Analysis(artificialanalysis.ai)
    42comments
  14. Line Scan Photos from MUNI Heritage Weekend in San Francisco(lawrence.lu)
    3comments
  15. I don't want to read what you didn't write(colinbreck.com)
    335comments
  16. Verda (Finland) raises $189M in Series B(verda.com)
    18comments
  17. AI coding has made CI a bottleneck, so we reworked ours to keep up(linear.app)
    325comments
  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. AI Is Antithetical to Learning(jola.dev)
    discuss
  26. The Advisory Group on Mathematics and Artificial Intelligence(terrytao.wordpress.com)
    75comments
  27. Claude Status – Elevated errors for multiple models(claude.com)
    98comments
  28. HERMES radio enables voice and data communication over vast distances(ieee.org)
    64comments
  29. Socrates vs. the Written Word (2011)(wondermark.com)
    37comments
  30. Python Workers are now generally available(cloudflare.com)
    39comments

Type Punning in C and C++

34 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.

57m agoHN ↗

It continues with

and most blog posts on the topic get it wrong.

This smells like Claudism/LLMish.

48m 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.)

41m 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.

44m agoHN ↗

Is it necessary to use the lowest possible font weight?

36m 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

22m 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.

17m agoHN ↗

I don't understand the example in "Why C and C++ Differ".

Shouldn't the code return 3 in the base case and 4 if the check for 2 was assumed to always hold ?