Timeline for Pseudofactorial
Current License: CC BY-SA 4.0
10 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Mar 30, 2023 at 15:14 | comment | added | Deadcode |
Ah, I see! Interesting. I was familiar with that site, and had already tried various versions of compilers on it with your code, but it wouldn't have occurred to me to try -O1, as I'd never seen a gcc exploit before that relied on that rather than the default -O0. Why not also include a Try it online! link?
|
|
| Mar 30, 2023 at 12:08 | comment | added | anatolyg |
@Deadcode It works in all gcc versions (but only with -O1), and in some clang versions. Fortunately, we have Compiler Explorer! I added a link so anyone could check these results.
|
|
| Mar 30, 2023 at 12:01 | history | edited | anatolyg | CC BY-SA 4.0 |
details on how to reproduce the result
|
| Mar 29, 2023 at 19:36 | comment | added | Deadcode | This doesn't work anymore on modern versions of GCC or clang (if it ever did), because EAX gets overwritten by another value, but here's a mockup of how it probably worked: Try it online! – I wouldn't be surprised if it only worked on a narrow range of compiler versions. | |
| Jun 13, 2016 at 7:04 | comment | added | anatolyg |
@SteveCox Both cdecl and stdcall use the same method for return-value, so I guess x86 is enough
|
|
| Jun 13, 2016 at 7:01 | history | edited | anatolyg | CC BY-SA 3.0 |
added 11 characters in body
|
| Jun 10, 2016 at 20:32 | comment | added | Steve Cox | if you're taking advantage of a calling convention then this should really be marked "C (cdecl)" rather than just "C" | |
| Jun 9, 2016 at 23:54 | comment | added | anatolyg |
C has the default-int rule - all omitted types are int by default (including the return value). It works for function arguments if they are declared using the so-called "old-style" syntax. The declaration with explicitly defined types would be int d(n,k,b,t) int n,k,b,t; {...}
|
|
| Jun 9, 2016 at 23:49 | comment | added | Tony Ruth | How do you get away with not declaring the type of n, k, b,and t? | |
| Jun 9, 2016 at 23:47 | history | answered | anatolyg | CC BY-SA 3.0 |