>codeshame
Score: 0.0 out of 10
0.0/10
public roast
verdict: needs_serious_help
C
4 lines
3 focus points

"Return of the dangling pointer of doom!"

Here is the breakdown of what hurt your score, plus a cleaned-up version you can use as a starting point. If the roast feels fair, share it. If it feels unfair, paste better code next time.

score

0.0 / 10

fixed output

3 lines

line delta

-1

// summary

Your strongest next move is to fix the highest-severity issue first, then compare the cleanup against the original before shipping anything.

// sharing

Public roasts can land in the leaderboard. Private reviews stay out of it and are better for real code you do not want exposed.

// compare

Use the original and fixed blocks below to spot naming, logic, and structure changes quickly instead of reading the whole thing twice.

//your_submission
DanglingPointerDisaster.c
int* getLocalValue() {
    int tempValue = 42;
    return &tempValue; 
}
//detailed_analysis
!

Dangling Pointer

You're returning the address of a local variable, which is immediately destroyed when the function ends. This is like giving someone a map to a house that doesn't exist, but hey, at least you tried?
!

Memory Safety

Your code is a crash waiting to happen. The caller will try to access memory that's already been freed, causing a segfault or other undefined behavior. It's like playing a game of Russian roulette, but with pointers!
?

Code Smell

Why are you even returning a pointer to an int? Just return the int itself! This is like trying to solve a simple math problem with a blowtorch and a sledgehammer.
//suggested_fix

original: 4 lines · fixed: 3 lines

DanglingPointerDisaster_fixed.c
+int getLocalValue() {
+ return 42;
+}