Timeline for Simple Singly-Linked List class
Current License: CC BY-SA 4.0
13 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Jan 11, 2022 at 17:14 | comment | added | Davislor |
In C++11 and later, Clang also supports an attribute [[clang:musttail]] on return statements (with some restrictions, such that it cannot be used for mutual recursion).
|
|
Jan 11, 2022 at 16:34 | comment | added | Davislor |
@Deduplicator Some pragmatic advice in those situations: GCC offers an -foptimize-sibling-calls command-line option, and Clang has that, several other options that seem to relate to tail calls, and an __attribute__((musttail)) that you can put on a specific function.
|
|
Jan 11, 2022 at 14:00 | comment | added | Deduplicator | @Davislor Some people who need to completely verify their code does what it should are restricted from using compiler-optimizations, as they are extremely hard to verify. Also, some prefer debugging at least sometimes without any optimization to get in the way. Why make either impossible? Anyway, signing off. | |
Jan 11, 2022 at 5:46 | comment | added | Davislor | @Deduplicator If your compiler is so bad that any tail-recursive code will crash, why are you using it? You certainly wouldn’t want to debug your program with flags that generate completely different code than your production version. You’ll never be able to duplicate the bugs that way. | |
Jan 11, 2022 at 3:29 | comment | added | Deduplicator | @Davislor Slow isn't the problem. Tail-calls not being optimized, thus making stackframes pile up, and causing a stack overflow, is. | |
Jan 11, 2022 at 2:58 | comment | added | Davislor | @Deduplicator There is one compiler in real-world use that defaults to EBCDIC as the execution character set, so that’s not as hypothetical as the others. If the only concern is that tail calls will be slow if you turn off all optimizations, I don’t think that’s a strong case for avoiding them. You should expect that to produce slow code. But, anyway, the OP can read our comments and decide. | |
Jan 11, 2022 at 2:37 | comment | added | Deduplicator | @Davislor The most widely used compiler-option resulting in that is using none at all, I think. While requiring two's complement is reasonable enough for most of us if it simplifies things, requiring ASCII+ has more pitfalls. | |
Jan 11, 2022 at 2:16 | comment | added | Davislor | @Deduplicator Is there a compiler in wide use that doesn’t do this optimization on production code, or is this like, the standard doesn’t formally require two’s-complement arithmetic or an ASCII-compatible character set? | |
Jan 11, 2022 at 1:02 | comment | added | Deduplicator | @Davislor One can care about efficiency, but still prefer working code for non-optimizing or badly optimizing implementations. | |
Jan 10, 2022 at 1:03 | comment | added | Davislor | Respectfully disagree on the advice that we should avoid tail-recursion because C++ doesn’t formally “mandate” tail-call optimization. Every significant compiler has done it, for decades. If you care about optimization, and you’re using a compiler that doesn’t even do that, the tool you are using does not meet your requirements. | |
Jan 9, 2022 at 16:27 | vote | accept | xxnoflz | ||
Jan 9, 2022 at 14:10 | history | edited | Toby Speight | CC BY-SA 4.0 |
deleted 100 characters in body
|
Jan 9, 2022 at 14:05 | history | answered | Toby Speight | CC BY-SA 4.0 |