The sad truth is: this can "Harm a Mac".
The actual example given in the body for the question: this very likely did not harm the device. Granted.
But as a general answer to the question in the title:
It depends on which type of Mac we are talking about. The advice and reasoning given so far on this question or in the comments is not universally true and can be quite dangerous! There is too much trust and faith put into the mere belief that Apple hardware is just the best there is.
It is simply not true that Apple designs now or designed in the past all its systems to really not harm themselves through overheating. While it is true that this should not happen it is also true that it does happen. And did:
The prime example for this are the MacBook Pros, especially those from 2010-2012.
While the Intel chip that is primarily stressed with yes
on all threads for a prolonged time will throttle down, will handle high temperatures quite well and even the OS will kick in and ramp up kernel_task to do nothing useful except help cool down the machine, the discrete chip on the same heatpipe is the vulnerable counterpart there.
Stressing these systems needlessly, like with yes
, hastens the RadeonGate graphics chip failure. There are numerous examples of questions to the most heavily effected 2011 8,2 on this very web-site.
This GPU failure is a thermal issue. There are even guides out there on how to kill the machine by simply running heavy 3D rendering or benchmarks for a time. These systems were advertised for but not suited for e.g. rendering or gaming. Class action lawsuits (only threatened) and Repair Extension Programs speak for themselves.
/dev/null
port eventually so you will need oversized pistons, but wait until you see smoke from the exhaust before rushing to a mechanic.