Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »

Welcome to Software Development on Codidact!

Will you help us build our independent community of developers helping developers? We're small and trying to grow. We welcome questions about all aspects of software development, from design to code to QA and more. Got questions? Got answers? Got code you'd like someone to review? Please join us.

Activity for Lundin‭

Type On... Excerpt Status Date
Comment Post #277537 @obround I'd be surprised if a compiler didn't store small size arrays inside registers, given that the array address is never taken. Easy enough to prove, here is an array stored in registers: https://godbolt.org/z/Yb134Y
(more)
almost 5 years ago
Edit Post #277540 Initial revision almost 5 years ago
Answer A: How does the community feel about resource requests?
These are fine, IMO: - Here is my specification of what the program should do /--/. I'm stuck at x, (optionally: here is my code), where do I go from here? - Is this implementation of x (code follows) fine in terms of parameters y and z? Where parameters could be execution speed, memory use, read...
(more)
almost 5 years ago
Edit Post #277537 Post edited:
almost 5 years ago
Edit Post #277537 Post edited:
almost 5 years ago
Edit Post #277537 Initial revision almost 5 years ago
Answer A: What gets allocated on the stack and the heap?
"Stack vs heap" is a common over-simplification and not really a meaningful one, since those two areas have quite different, specialized uses. And no, those are not the only memory regions used by your program. To understand where variables end up, we must understand how a computer works. Physical...
(more)
almost 5 years ago
Edit Post #277536 Initial revision almost 5 years ago
Question What gets allocated on the stack and the heap?
I was told by my professor/book that computer programs use two kinds of memory and that all variables get allocated either on the stack or on the heap. Is this true? How can I tell where a variable gets allocated? Does the compiler handle allocation differently depending on which programming language...
(more)
almost 5 years ago
Edit Post #277488 Post edited:
almost 5 years ago
Edit Post #277488 Initial revision almost 5 years ago
Answer A: What is undefined behavior and how does it work?
Undefined behavior (informally "UB") is a formal term in the C language, defined in C17 3.4.3 > undefined behavior > behavior, upon use of a nonportable or erroneous program construct or of erroneous data, for which this International Standard imposes no requirements Meaning that anything ca...
(more)
almost 5 years ago
Edit Post #277486 Initial revision almost 5 years ago
Question What is undefined behavior and how does it work?
I have created this sensational program: #include int func (void) { int local=5; return &local; } int main (void) { printf("%d\n", func()); } This prints `5` even though I'm returning a pointer to a local variable. It did not pro...
(more)
almost 5 years ago
Comment Post #277478 Product recommendation questions ought to be off-topic. Design recommendations asking "what's the best way" need to specify the "best" criteria. Execution speed, RAM use, safety, dev time, portability etc etc.
(more)
almost 5 years ago
Comment Post #277423 "Never. The returned value is always meaningful and has always to be treated." That kind of depends on how the function is written, yeah? Take `strcpy` as one example of a function with an often useless return value.
(more)
almost 5 years ago
Comment Post #277423 `warn_unused_result` is pretty useless, since it doesn't work unless you pollute your code with non-standard `__attribute__` crap. There is no reason why they can't check for it in standard C.
(more)
almost 5 years ago
Comment Post #277429 This is one of the things I'm hoping there will be a place for on this site or another Codidact one. Program design is complex and every programmer needs it.
(more)
almost 5 years ago
Edit Post #277217 Post edited:
Changes to reflect an edit of the question.
almost 5 years ago
Edit Post #277341 Post edited:
almost 5 years ago
Comment Post #277331 Not really. The order of evaluation of + and - is unspecified, so you can't reliably tell if that example evaluates as `(arr - 1) + choice` or `arr - (1 + choice)`. At least the former sub-expression is undefined behavior. In practice the compiler will likely replace it all with hard-coded addresses,...
(more)
almost 5 years ago
Edit Post #277341 Post edited:
almost 5 years ago
Edit Post #277341 Post edited:
almost 5 years ago
Edit Post #277341 Initial revision almost 5 years ago
Answer A: What must a C compiler do when it finds an error?
The C standard does not speak of "errors" and "warnings", those are not formal terms. The compiler is only required to produce a diagnostic message, as specified in C11 5.1.1.3: > Diagnostics > A conforming implementation shall produce at least one diagnostic message (identified in an implemen...
(more)
almost 5 years ago
Edit Post #277340 Initial revision almost 5 years ago
Question What must a C compiler do when it finds an error?
What exactly must a C compiler do when it finds a compile-time error? The most obvious kind of errors are language syntax errors, but the C standard also speaks of constraints, which are rules that a C program is not allowed to break. Doing so is a so-called constraint violation. Upon finding ...
(more)
almost 5 years ago
Comment Post #277331 @klutt I think the remark is regarding this: https://stackoverflow.com/questions/52186834/pointer-from-integer-integer-from-pointer-without-a-cast-issues
(more)
almost 5 years ago
Comment Post #277331 If the C standard doesn't convince you, then think of common real-world scenarios: many architectures have memory protection traps from reading data from executable memory or executing code from data memory. Suppose your array is located at the very border of data memory on a certain machine and by ...
(more)
almost 5 years ago
Comment Post #277331 You can't demonstrate that something isn't undefined behavior by running the code, all you prove with that is that you got lucky. You can however in some cases demonstrate that something _is_ UB by disassembling the code and watch where it went wrong.
(more)
almost 5 years ago
Edit Post #277217 Post edited:
almost 5 years ago
Comment Post #277215 Actually, `char *ptr = arr[-1];` is not valid, there needs to be an `&` or it's a constraint violation of simple assignment. I didn't think of it when I originally answered the question.
(more)
almost 5 years ago
Edit Post #277312 Initial revision almost 5 years ago
Answer A: What is a standard definition (or a CS theory based formal definition) for Escaping?
The term escape sequence apparently dates back to the telegraph and pre-computer technology, according to wikipedia: https://en.wikipedia.org/wiki/Escapesequence. So I doubt there's an universally relevant definition of the term. I would guess that the term, in the scope of computer science, origi...
(more)
almost 5 years ago
Comment Post #277235 @msh210 Not at all. For example for a Code Golf site, it would make perfect sense for the question not to make any attempt to solve it. It is open for discussion whether Code Golf is on topic or not, separate discussion here: https://software.codidact.com/questions/277263
(more)
almost 5 years ago
Comment Post #277263 @Monica From SE we can get a very good idea which categories that are likely to turn out to be high traffic ones and become independent sites in the future. Code review, databases etc.
(more)
almost 5 years ago
Comment Post #277266 In this particular case, a cast to void means "I am purposely ignoring the return value", but silently ignoring the return value could mean anything. Including "I forgot to check the return value" or "trust me, I don't know what I'm doing". gcc/clang etc don't even give diagnostics when you ignore th...
(more)
almost 5 years ago
Comment Post #277263 My reasoning is that the mentioned category suggestions all have their own sites in the SE network, so they might eventually end up like that here as well.
(more)
almost 5 years ago
Edit Post #277265 Initial revision almost 5 years ago
Answer A: Should I cast to (void) when I do not use the return value
Yes, it is generally good practice to always cast the return value of functions to `(void)` if not used. This is self-documenting code showing that you aren't using the return value on purpose and did not just forget it by accident. For reference, either using the return value or casting it to `v...
(more)
almost 5 years ago
Comment Post #277263 I agree, I think it would be best to branch off all things that aren't practical programming questions into categories of their own, if we are to allow them. Maybe we could have a broader discussion about which categories that make sense to have overall? Some suggestions: Code golf, Code review, ...
(more)
almost 5 years ago
Comment Post #277249 @Moshi The proposed site https://meta.codidact.com/questions/74991 is about hobbyist single board computers, which unlike microcontroller programming is borderline off-topic on the electronics site. There's a big difference between rolling out your own microcontroller solution or buy a hobbyist kit. ...
(more)
almost 5 years ago
Comment Post #277235 @Monica Please propose that in an answer so that the community can vote for/against. I'll edit the question when there seems to be a community consensus for/against something. Though I have no idea how many active users there are and how many votes that should be regarded as "consensus".
(more)
almost 5 years ago
Comment Post #277249 "Over on Writing, we have a category for Challenges. I don't see why we can't have a similar Code Golf/Programming Challenges category here as well." That's a good idea. We could put code golf as well as code review in special categories.
(more)
almost 5 years ago
Comment Post #277249 It always felt out of place and it always ended up with questions where the problem could be either software and hardware. This is quite normal in electronics. The problem was that in case you found out that the problem was hardware-related, the question suddenly turned off-topic and had to be closed...
(more)
almost 5 years ago
Comment Post #277249 "I believe Electrical is purely for hardware questions (someone correct me if I'm wrong)". Yes this is wrong. It has pretty much the same scope as electronics at SE always had. Microcontroller programming etc was always perfectly on-topic. This proposal is based on me being one of the all time top us...
(more)
almost 5 years ago
Comment Post #277249 "I don't really see the point of listing specific things as "on topic." " The point would be that people know the purpose of the site in the form of a brief summary.
(more)
almost 5 years ago
Comment Post #277235 @James Yes indeed.
(more)
almost 5 years ago
Comment Post #277235 @James Yes, mainly all PC helpdesk kind of questions.
(more)
almost 5 years ago
Comment Post #277243 The reason I put it there is because it was always off-topic on SO. Other than that, I have no opinion for or against keeping it.
(more)
almost 5 years ago