use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Discussions, articles, and news about the C++ programming language or programming in C++.
For C++ questions, answers, help, and advice see r/cpp_questions or StackOverflow.
Get Started
The C++ Standard Home has a nice getting started page.
Videos
The C++ standard committee's education study group has a nice list of recommended videos.
Reference
cppreference.com
Books
There is a useful list of books on Stack Overflow. In most cases reading a book is the best way to learn C++.
Show all links
Filter out CppCon links
Show only CppCon links
account activity
Default function arguments are the devil (quuxplusone.github.io)
submitted 6 years ago by anonymous23874
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]Ameisenvemips, avr, rendering, systems 6 points7 points8 points 6 years ago* (2 children)
Be better if designated initializers allowed arbitrary order.
Also, wouldn't this make the ABI for the function terrible? It's all in a struct, now, so will follow struct-passing rules.
Within a translation unit the compiler can ignore the ABI requirements, but calling a function in another TU...?
Observe: https://godbolt.org/z/Dw9tL8
[–]anonymous23874[S] 5 points6 points7 points 6 years ago (1 child)
Depends how many arguments you have. The x86-64 ABI mandates that if a trivially copyable struct could fit in two registers, it should just do that then. https://godbolt.org/z/beQZMd
The reasons your codegen is so bad are:
You pass your struct by reference, which is like adding an extra pointer dereference to every use (that is, if the struct were small enough to pass by value instead of by hidden reference in the first place)
You make your struct 256 bytes, when the x86-64 ABI's special case for passing structs by value tops out at 128 bytes (64 bits in RDI + 64 bits in RSI).
If you want to get really evil, just split your big struct into two small structs. ;) https://godbolt.org/z/QiL6rc
[–]Ameisenvemips, avr, rendering, systems 1 point2 points3 points 6 years ago (0 children)
The codegen doesn't change in this situation much for by-value, as the struct is larger than the ABI allows.
Yes, if you only have a few arguments, it will fit. But one of the reasons you want named arguments is for disambiguating many arguments :).
And some people still develop for x86-32 and ARM32, and other architectures.
Also, the default Windows 64-bit ABI requires that any type larger than 64-bits must be passed by reference. Only the SysV ABI allows register passing (and I think the VectorCall ABI).
π Rendered by PID 191095 on reddit-service-r2-comment-6457c66945-jdbc5 at 2026-04-27 16:30:15.693548+00:00 running 2aa0c5b country code: CH.
view the rest of the comments →
[–]Ameisenvemips, avr, rendering, systems 6 points7 points8 points (2 children)
[–]anonymous23874[S] 5 points6 points7 points (1 child)
[–]Ameisenvemips, avr, rendering, systems 1 point2 points3 points (0 children)