Hacker News new | ask | show | jobs
by fargle 1552 days ago
> strcpy in C is Turing complete

How so? You've made this claim twice (https://news.ycombinator.com/item?id=27910640), but I can find nothing else to back this up. We know about C++ templates "accidentally" being discovered to be Turing complete, but I've never heard of strcpy() being so...

    while((*p++=*q++));
... I'm not seeing it.

Honest question, can you shed light on how this can be?

1 comments

Strcpy is a good setup for a buffer overflow despite having to run a gauntlet of countermeasures to really pull it off in 2022.
Well, OK, but that isn't fair to say "C" or strcpy(). That's the implementation - so is it surprising that the common underlying implementation of "C" can be coerced into indeterminate or even Turing complete behavior?

It's fair to say that C allows unsafe calls. It's useless to point out that undefined-behavior and unsafe calls could result in Turing completeness. Strcpy() is not Turing complete - it doesn't automatically detect and protect against unsafe usages. That are evil.