You are viewing a single thread.
View all comments View context
2 points
*

Clang won’t tell you if you’re missing a return statement, even with all warnings on and will just let it crash during runtime. Static analysis won’t save you from all stupid mistakes.

permalink
report
parent
reply
5 points

clangd should have warned you about this before you even considered compiling.

permalink
report
parent
reply
2 points

Thanks, I’ve tried it and it works a lot better than the built in intelli-sense.

permalink
report
parent
reply
3 points

Clang won’t tell you if you’re missing a return statement.

Is this C++? Have you got some code examples?

I’ve been writing C++ for 20+ years and the last compiler I encountered this with was Borland’s. In the late 90s.

permalink
report
parent
reply
1 point
*

It’s on the company computer, but I have a backup from earlier today that seems to have the same code.

bool load_metadata() {
    uint8_t marker_field = EEPROM.read(0);
    // Write to ROM if marker has not been set
    if (marker_field != MARKER) {
        metadata = {
            0,
        };
        EEPROM.put(1, metadata);
        EEPROM.update(0, MARKER);
    }
    else {
        EEPROM.get(1, metadata);
    }
}

I have to admit, my experience with C++ is rather limited, last Monday was the first time in my life that I used a C++ compiler. I had some issues getting it to work with Visual Studio, so I ended up using VS Code WSL with clang 😅.

permalink
report
parent
reply
2 points

Does this compile with -Wall -Werror? (might not be an option if your dependencies’ headers contain warnings)

Looks like it may be embedded code for a SoC or similar. The only things I can think of is that the tool chain you’re using maybe non-standard… or you’re invoking the dreaded Undefined Behaviour somewhere :(

permalink
report
parent
reply
12 points

Static analysis won’t save you from all of them, but they will definitely save you from the great majority of the ones ProgrammerHumor seems to get worked up about.

I still see people sharing ancient memes about pouring over code for hours looking for mismatched curly braces, missing semicolons, and greek question marks. These and the bulk of minor syntax problems like them should all be complete non-issues with modern tooling.

permalink
report
parent
reply
1 point
Deleted by creator
permalink
report
parent
reply
6 points

permalink
report
parent
reply

Programmer Humor

!programmerhumor@lemmy.ml

Create post

Post funny things about programming here! (Or just rant about your favourite programming language.)

Rules:

  • Posts must be relevant to programming, programmers, or computer science.
  • No NSFW content.
  • Jokes must be in good taste. No hate speech, bigotry, etc.

Community stats

  • 5.2K

    Monthly active users

  • 1.5K

    Posts

  • 35K

    Comments