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.

Posts by Lundin‭

143 posts
60%
+1 −0
Meta How are software recommendations handled?

See Software recommendations category. Referring to my own answer there, I think these questions should only be on-topic in case the OP manages to narrow down the scope sufficiently. In case the qu...

posted 11mo ago by Lundin‭

Answer
66%
+2 −0
Q&A Storing more bytes than a union member has, but less than the union size, with memcpy(3)

memcpy(&y.t, &x, sizeof(x)); is a bit fishy since it would have made more sense to copy into &y or &y.s. None of this is necessarily UB however. Regarding strict aliasing, it doesn...

posted 11mo ago by Lundin‭  ·  edited 11mo ago by Lundin‭

Answer
66%
+2 −0
Q&A Can freed pointers undergo lvalue conversion?

p is assigned a value and then it becomes indeterminate when the pointed at object has reached the end of its lifetime (C17 6.2.4). Pointers may have trap representations (C17 6.2.6.1/5) and in ca...

posted 1y ago by Lundin‭

Answer
83%
+8 −0
Q&A memcmp(3) memory containing invalid values

Regarding undefined behavior/uninitialized variables of automatic storage duration First of all there's some misconceptions here. if (x == 0) is UB only because x was declared as a local variable...

posted 1y ago by Lundin‭  ·  edited 1y ago by Lundin‭

Answer
88%
+14 −0
Meta Should we allow answers generated by ChatGPT?

After some more experience from this bot over a couple of months, I would say that we should ban it simply because: The answers it gives are often wrong. ChatGPT has been hyped up ridiculously. I...

posted 1y ago by Lundin‭

Answer
75%
+4 −0
Q&A Is partial allocation of an object Undefined Behavior?

Since I don't think the C standard says anything explicitly about cases like this, it is probably undefined behavior, under the "not mentioned in the standard" variety. If something isn't mentioned...

posted 1y ago by Lundin‭

Answer
71%
+3 −0
Q&A Strict aliasing rules and function boundaries

Assuming that there are no alignment problems between the two pointer types (impl-defined), the code is otherwise well-defined. As per the quoted 6.3.2.3 C allows pretty much any form of wild and c...

posted 1y ago by Lundin‭

Answer
75%
+4 −0
Meta Are questions about language design on-topic?

The ambition of this site was always to give more room for subjective and big picture questions compared with Someplace Else. However, I believe programming language design falls under the topic of...

posted 1y ago by Lundin‭

Answer
75%
+7 −1
Meta Should asking about book recommendations directly connected to software development be on-topic?

As someone who spent a lot of time trying to get this to work on Stack Overflow, I would advise against it. Some background story of my merry adventures with book lists: The story starts around...

posted 1y ago by Lundin‭  ·  edited 9mo ago by Lundin‭

Answer
83%
+8 −0
Q&A C naming convention, module trigrams?

For what it's worth, I have some 20 years of experience designing embedded C systems, with large and small code bases both. Code design is some of the hardest things to do, since books about object...

posted 1y ago by Lundin‭  ·  edited 1y ago by Lundin‭

Answer
77%
+5 −0
Q&A Cast uninitialized variable to (void)

It depends. This boils down to whether or not the expression cast to void contains any side effects, such as accessing a volatile-qualified object or modifying any object. C17 6.3.2.2: If an ex...

posted 1y ago by Lundin‭  ·  edited 1y ago by Ethan‭

Answer
71%
+3 −0
Meta Asking and answering FAQ style questions

Yes it is fine and probably encouraged even. I have written several self-answered Q&A here and they were mostly well-received. They aren't all that easy to write though, especially getting the ...

posted 1y ago by Lundin‭

Answer
71%
+3 −0
Meta Renaming GNU/Linux tag to gnu

I don't think GNU can be used as a stand-alone tag. Apart from the OS, GNU is also a tool collection of various programs, many used for programming, making is a very ambiguous tag which can't stan...

posted 2y ago by Lundin‭

Answer
80%
+6 −0
Q&A How to write a macro that discards the const qualifier, for any type?

Ignoring the numerous forms of undefined behavior that casting away const might invoke, the blunt but simple and standard solution is just to cast to (void*). char* foo (const char* str) { r...

posted 2y ago by Lundin‭  ·  edited 2y ago by Lundin‭

Answer
90%
+17 −0
Meta How can we grow this community?

By having decent source code formatting that isn't completely inferior to other sites like Stack Overflow. We might want to post/view snippets longer than 13 lines without suffering some scroll whe...

posted 2y ago by Lundin‭

Answer
40%
+2 −4
Q&A Should I check if pointer parameters are null pointers?

The kind of comments telling you to add checks against null are typically coming from programmers mostly used to deal with higher level programming languages. They think that generally, more explic...

posted 2y ago by Lundin‭  ·  edited 2y ago by Lundin‭

Answer
86%
+11 −0
Q&A Should I check if pointer parameters are null pointers?

When writing any form of custom function such as this: void func (int* a, int* b) Should I add code to check if a and b are null pointers or not? if(a == NULL) /* error handling */ When po...

4 answers  ·  posted 2y ago by Lundin‭  ·  last activity 2y ago by Dirk Herrmann‭

63%
+5 −2
Q&A Which functions in the C standard library must always be avoided?

Standard library functions that should never be used: setjmp.h setjmp() Together with longjmp(), these functions are widely recogniced as incredibly dangerous to use: they lead to spaghetti ...

posted 2y ago by Lundin‭  ·  edited 2y ago by Lundin‭

Answer
83%
+8 −0
Q&A Which functions in the C standard library must always be avoided?

It would seem that the C standard library is a collection of diverse functions that pretty much just ended up in the standard by tradition or "accident", rather than through some careful plan or ra...

1 answer  ·  posted 2y ago by Lundin‭  ·  last activity 2y ago by Lundin‭

75%
+4 −0
Q&A C++ exit code -1073740940

C++ doesn't have error codes/exit codes other than return 0; / EXIT_SUCCESS / EXIT_FAILURE. The code you are getting is from the OS when your program crashes from a run-time error. -1073740940 is ...

posted 2y ago by Lundin‭

Answer
71%
+3 −0
Q&A noreturn function with non-void return type

Syntax-wise it is a function specifier and may in theory appear everywhere where inline (or rather the syntax item function-specifier:) can appear, since the standard doesn't say otherwise. Though ...

posted 2y ago by Lundin‭

Answer
77%
+5 −0
Meta Software recommendations category

At some extent, you can ask about (programming-related) software recommendations if you manage to narrow down the scope to something specific. A question like "which one of compiler x and compiler ...

posted 2y ago by Lundin‭

Answer
77%
+5 −0
Q&A Is it OK to use scanf with a void pointer?

Void pointers are compatible with every other object pointer type and as mentioned in another answer, 7.21.6/10 speaks of the type of the pointed at object, not the type of the pointer. This is con...

posted 2y ago by Lundin‭  ·  edited 2y ago by Lundin‭

Answer
75%
+4 −0
Q&A When does it not work to dereference the pointer for sizeof during malloc?

In addition to all the examples I gave in my answer to the linked post, all scenarios where p is a pointer to incomplete type fails. Not just the void* scenario, but also when p is a pointer to an ...

posted 2y ago by Lundin‭

Answer
75%
+4 −0
Code Reviews stpecpy(): Design a better string copy function that truncates

Performance-wise, I'd benchmark this vs if(memchr(src,'\0',n)==src+n) memcpy(dst, src, n); because it isn't obvious at least to me if that's faster or slower than your custom function. Regarding...

posted 2y ago by Lundin‭

Answer