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
Edit Post #277891 Post edited:
about 4 years ago
Edit Post #277891 Initial revision about 4 years ago
Question Meaning of the tag software practices?
Some new tag "software practices" just popped up, no wiki. What's the purpose of this tag and how is it useful? What exactly in software development is not "software practices"? Seems quite superfluous and very broad. Is it supposed to mark questions that are subjective or asking for best prac...
(more)
about 4 years ago
Comment Post #277551 I'm thinking the root of the problem might be the programmer who writes 140 symbols long LoC and not the site?
(more)
about 4 years ago
Comment Post #277265 @Estela It turns cumbersome to cast everything to `void` when using various common, poorly-designed standard library functions such as `printf`, `strcpy` etc. You do not commonly use the result of those (since it's useless most of the time).
(more)
about 4 years ago
Comment Post #277551 Maybe I don't understand the problem, but code shouldn't get automatically line-wrapped, since doing so might affect the behavior of it in a lot of languages.
(more)
about 4 years ago
Edit Post #277576 Post edited:
about 4 years ago
Edit Post #277576 Initial revision about 4 years ago
Answer A: Generate SIGSEGV without undefined behaviour.
`SIGSEGV` is defined in the C header `signal.h`. To generate the signal, it should be sufficient to just do `raise(SIGSEGV);`. As far as I know, this is well-defined behavior.
(more)
about 4 years ago
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)
about 4 years ago
Edit Post #277540 Initial revision about 4 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)
about 4 years ago
Edit Post #277537 Post edited:
about 4 years ago
Edit Post #277537 Post edited:
about 4 years ago
Edit Post #277537 Initial revision about 4 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)
about 4 years ago
Edit Post #277536 Initial revision about 4 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)
about 4 years ago
Edit Post #277488 Post edited:
about 4 years ago
Edit Post #277488 Initial revision about 4 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)
about 4 years ago
Edit Post #277486 Initial revision about 4 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)
about 4 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)
about 4 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)
about 4 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)
about 4 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)
about 4 years ago
Edit Post #277217 Post edited:
Changes to reflect an edit of the question.
about 4 years ago
Edit Post #277341 Post edited:
about 4 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)
about 4 years ago
Edit Post #277341 Post edited:
about 4 years ago
Edit Post #277341 Post edited:
about 4 years ago
Edit Post #277341 Initial revision about 4 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)
about 4 years ago
Edit Post #277340 Initial revision about 4 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)
about 4 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)
about 4 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)
over 4 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)
over 4 years ago
Edit Post #277217 Post edited:
over 4 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)
over 4 years ago
Edit Post #277312 Initial revision over 4 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)
over 4 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)
over 4 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)
over 4 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)
over 4 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)
over 4 years ago
Edit Post #277265 Initial revision over 4 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)
over 4 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)
over 4 years ago