These functions make Reddit programmers shit their pants. They’re not “safe” enough lmao

These functions make Reddit programmers shit their pants. They’re not “safe” enough lmao

  1. 3 weeks ago
    Anonymous

    Whenever i use calloc it gives me index out of bounds, so i switch to malloc and use a for loop to initialize, and everything works

    • 3 weeks ago
      Anonymous

      how do you use calloc? also dont use a for loop for initializing to 0, use memset

      • 3 weeks ago
        Anonymous

        pretty sure I used the most basic example
        int* a = (int*)calloc(n, sizeof(int));

        • 3 weeks ago
          Anonymous

          yes this works, you must be doing something else wrong

        • 3 weeks ago
          Anonymous

          [log in to view media]

          You shouldn't cast the return values of malloc and calloc. That's considered bad practice

          • 2 weeks ago
            Anonymous

            >That's considered bad practice
            by whom?

            • 2 weeks ago
              Anonymous

              By people who use C. homosexuals who use C++ disagree.
              Remember, C is for chad and C++ is for homosexuals.

            • 2 weeks ago
              Anonymous

              it's just a general principle. the idea is that if you change the type, you don't have to change the cast too. in that particular example, they should also write ``sizeof(*a)`` instead of ``sizeof(int)`` for the same reason. i'm sure there's other reasons like accidentally hiding a typo by casting away the error.

  2. 3 weeks ago
    Anonymous

    [log in to view media]

    >another "i just lost an argument with a Rust user and need to cope hard" thread

    • 3 weeks ago
      Anonymous

      you will never be a real woman

    • 3 weeks ago
      Anonymous

      Just use Rust and chill
      Continue suffering, C++ gays

    • 2 weeks ago
      Anonymous

      whatever, I could make a version with the 473892789375 keywords, libraries and punctuation squigglies you have to learn as part of a rust 101 course, but this reply alone is barely worth the effort of giving the time of day to a rust shill

    • 2 weeks ago
      Anonymous

      >i just lost an argument with a Rust user
      That's an impossibility, just like you can never "lose" an argument pointing out how shitty and worthless systemd is.

    • 2 weeks ago
      Anonymous

      OP its not about being safe, its about a large project having a memory issue due to human error which is going to only be evident on runtime it doesnt matter if you have 10 million hours with C/C++ people make mistakes.

      I am assuming its just poor bait at this point but i will still answer you. There have a been a plethora of vulnerability exploits in Windows over the years due to human errors.

      You mean the operating systems with hundreds of CVEs?

      This level of delusion is off the charts..

      Programs written in C:
      -Linux, Windows, OS X
      -Browsers like Chrome, Safari, Firefox (Firefox has way more C/C++ than Rust)
      -Servers like Apache/NGINX
      -Databases like Oracle Database, MySQL, MS SQL Server, and PostgreSQL
      -Programming languages like Python, Ruby, PHP, JavaScript and even Java run on C (Python is just C code, interpreters like V8 for JavaScript or the JVM are written in C)
      -Almost any game
      -Office Applications
      -Embedded Systems
      - …

      Let me put it like this:
      EVERYTHING IS FUCKING C YOU FUCKING QUEERS

      • 2 weeks ago
        Anonymous

        Kernels were written in C because it was a better option than ALGOL. People shilling C don’t really use C for anything more than a fizzbuzz.

    • 2 weeks ago
      Anonymous

      You can't lose an argument to a tranny shilling a language with a dependency system so clowning it produces 1.5gb hello worlds.

  3. 3 weeks ago
    Anonymous

    OP its not about being safe, its about a large project having a memory issue due to human error which is going to only be evident on runtime it doesnt matter if you have 10 million hours with C/C++ people make mistakes.

    • 3 weeks ago
      Anonymous

      [log in to view media]

      >another "i just lost an argument with a Rust user and need to cope hard" thread

      It's been good enough for the most important operating systems / software for half a century - just admit you're a shit programmer.

      • 3 weeks ago
        Anonymous

        I am assuming its just poor bait at this point but i will still answer you. There have a been a plethora of vulnerability exploits in Windows over the years due to human errors.

        • 3 weeks ago
          Anonymous

          (((((((((human))))))))) error

      • 3 weeks ago
        Anonymous

        >projecting

      • 3 weeks ago
        Anonymous

        You mean the operating systems with hundreds of CVEs?

        • 2 weeks ago
          Anonymous

          Yet, you're using them.

      • 3 weeks ago
        Anonymous

        This is what Conservatism in programming looks like

        • 3 weeks ago
          Anonymous

          not a conservative but holy shit we're going to end leftists so hard, you're gonna cry and piss your pants wishing we only gassed you to death

          • 3 weeks ago
            Anonymous

            [log in to view media]

            nah, you lost 2018, 2020 and you're gonna keep losing homosexual. we're on the right side of history. Heil Marx

            • 3 weeks ago
              Anonymous

              >arresting your own guys
              >think you're winning
              Only in the leftist clown world.

              • 3 weeks ago
                Anonymous

                [log in to view media]

                all faces here keep coping. also reminder you still lost your failed coup. punch a conservative and a garden gnome bleeds.

              • 2 weeks ago
                Anonymous

                >patriotfront
                >your own guys
                cope harder, and yes I'll keep stealing the ugly signs you keep hanging up over the highway, they're great for burning

            • 3 weeks ago
              Anonymous

              [log in to view media]

              yeah we're gonna lose, now put your guard down, we're losers and cant win haha put it down we cant win obviously therefore put your guard down theres no need to have a guard up if you're going up against losers haha you basically caught all of us now, there's nothing to worry about, society is safe again, so put your guard down. we won't do anything we swear

              • 3 weeks ago
                Anonymous

                [log in to view media]

                Do it. I love seeing another polkek put behind bars

              • 3 weeks ago
                Anonymous

                me and all my friends
                are gonna
                put you and all your friends
                into the dirt
                and nobody will ever find you
                nobody will even look for you
                nobody will care

              • 3 weeks ago
                Anonymous

                [log in to view media]

                this post is so edgy i could accidentally cut myself with it

            • 3 weeks ago
              Anonymous

              nazi's thought they are on the right side of the history, british empire thought they are on the right side of the history, russia thought they are on the right side of the history.
              history is written by the victors, but the next victors gonna go back and rewrite everything as they pleased. and then the next ones after them, and then the ones after, and the ones after to the point when truth will become obsolete.
              history is a collection of bad memes, the world how you know it is a lie

              • 2 weeks ago
                Anonymous

                such a midwit post its not worth engaging

                me and all my friends
                are gonna
                put you and all your friends
                into the dirt
                and nobody will ever find you
                nobody will even look for you
                nobody will care

                officially mindbroke. get fucked

            • 2 weeks ago
              Anonymous

              [log in to view media]

              >arresting your own guys
              >think you're winning
              Only in the leftist clown world.

              [log in to view media]

              Do it. I love seeing another polkek put behind bars

              [log in to view media]

              all faces here keep coping. also reminder you still lost your failed coup. punch a conservative and a garden gnome bleeds.

              Sirs this is a thread about managing memory in C/C++. Please leave us in peace and take your psychosis somewhere else amd remember to take ur valium thank u very much.

      • 2 weeks ago
        Anonymous

        You have no idea how much time was wasted on dealing with all that memory bullshit. It would be better if that time was used on something else.

  4. 3 weeks ago
    Anonymous

    int main() {
    int* n-word = malloc(-1);
    return;
    }

    • 2 weeks ago
      Anonymous

      Well, malloc's input is of type size_t, which is unsigned, so -1 wraps around and is therefore the maximum number of memory it could theoretically allocate, which, regardless of the system's bitwidth of size_t, will virtually always be larger than your available memory.
      Rustlets complain about this, citing it's "unsafe."

      • 2 weeks ago
        Anonymous

        Rust lets you cast from a negative integer to an unsigned integer (and it will behave the way you described) with no issue. It doesn't happen automatically, which is a good thing.

        • 2 weeks ago
          Anonymous

          [log in to view media]

          >It doesn't happen automatically, which is a good thing.
          Ah yes, the unsigned integer, a mystery as old as time, plebs hate it, midwits fear it, geniuses embrace it.

          • 2 weeks ago
            Anonymous

            There are no automatic casts (which is good), retard.

  5. 3 weeks ago
    Anonymous

    Why is there no "recalloc"? Why does C++ has no calloc? This shit pisses me off.

    • 3 weeks ago
      Anonymous

      c++ has vector, why would it need calloc?

      • 3 weeks ago
        Anonymous

        [log in to view media]

        Why is it always the same illiterate village idiot rescuing these crap threads from page 11?

        • 3 weeks ago
          Anonymous

          boo hoo

        • 3 weeks ago
          Anonymous

          necron-words are part of the chaos in the machine

          • 3 weeks ago
            Anonymous

            yup. necron-words are the force of nature

    • 3 weeks ago
      Anonymous

      >Why is there no "recalloc"?
      There'd be little point to it. Particularly considering realloc copies over the bytes from the previous allocation.
      >Why does C++ has no calloc?
      You can force operator new to call the default constructor on integers if need be.
      https://stackoverflow.com/a/7546745

    • 3 weeks ago
      Anonymous

      why not just call the c functions? also of you want "new" to 0 init your allocated memory, add brackets at the end like so "new type[amount]{}". now it will be 0 init

  6. 3 weeks ago
    Anonymous

    noo not free()

  7. 3 weeks ago
    Anonymous

    Java virtual machine allocates mem and garbage collects it for me. Seethe more tinkertranny.

  8. 3 weeks ago
    Anonymous

    Leftist programming paradigm is to restrict your freedom.

  9. 3 weeks ago
    Anonymous

    [log in to view media]

    why should we put railings up?
    Nobody is ever going to be stupid enough to fall of an edge.

    • 2 weeks ago
      Anonymous

      i didn't know children, animals, drunks, and retards can program

  10. 3 weeks ago
    bruce3434

    [log in to view media]

    So, what useful program have you created using these functions?

    • 3 weeks ago
      Anonymous

      >bruce3434
      hope you're trolling

      • 2 weeks ago
        Anonymous

        It’s a valid question

  11. 3 weeks ago
    Anonymous

    if you can acquire memory, you can release memory

  12. 3 weeks ago
    Anonymous

    I have never used memory allocation functions and did few shitty uni homework pieces with pointers just fine
    so why do you need them again?

    • 3 weeks ago
      Anonymous

      To avoid fragmentation and to understand what's actually going on between the code and the hardware.

  13. 3 weeks ago
    Anonymous

    Why are you using these instead of sbrk or mmap? Are those too unsafe?

    • 3 weeks ago
      Anonymous

      The correct level of abstraction is whatever I believe Dennis Ritchie to have shat out around the year 1970. If it's in C it's a carefully designed tradeoff that earns its upkeep. If it's not in C it's malignant bloat and wanting to use it is a sign of severe mental retardation.

      • 2 weeks ago
        Anonymous

        Exactly this.
        The best way to think about it is like basic atlas road maps and AASHTO compliant road signs.
        The abstractions from Unix were more than sufficient, and changing it is wasteful and confusing. It's like resigning the chevron for curves.
        Rust could be okay, if it was more like C. As it stands, it's bloat.

    • 3 weeks ago
      Anonymous

      Not granular enough.

  14. 2 weeks ago
    Anonymous

    And more impotant problem that can't be fixed by just wrapping new/delete into smart pointer is that no smart pointer will protect you from writing into freed memory or writing in same memory from different threads. Or shit like that.
    Rust solves much more bullshit than creates.

  15. 2 weeks ago
    Anonymous

    >Unsafe
    Literally woman/leftist propaganda in programming.
    Men take risks
    Women prefer safety over anything
    TOP FUCKING KEK

    • 2 weeks ago
      Anonymous

      The thing is, C is actually unsafe, programmers have just become too retarded to use it, and instead of manning up, they're pussying out and outsourcing their dumbness into some supposed inherent safety feature of a new language.
      Their imposing of Rust is a literal dragging down everyone to their level of retardation.

      • 2 weeks ago
        Anonymous

        Programming became accessible to masses. It was only a question of time. Masses drag everything down.

        • 2 weeks ago
          Anonymous

          So now it's the masses who are bad and actually it's good for computers to be controlled by a small group of shadowy elites?

        • 2 weeks ago
          Anonymous

          Rust is harder than you typical monkey language. You have to have at least some sort of understanding what you're doing, can just force program to run with enough hacks.. Or borrow checker just continue to humilate you over and over again.

      • 2 weeks ago
        Anonymous

        Why would Rust drag you down if you are actually smart?

        • 2 weeks ago
          Anonymous

          It's a retarded language, it might rub off on me.

          Look, I don't give a fuck what language you want to code in, but YOU'RE the ones telling ME what language I should use.

          • 2 weeks ago
            Anonymous

            Wrong. Nobody has any power over what language you use. Stop being deluded.

            • 2 weeks ago
              Anonymous

              [log in to view media]

              Ok then, go ahead and write device drivers with Javascript.
              You want to write drivers, use C. I'm not the one demanding client-side browser code to be written in C, and yet you insist on doing low-level stuff with Rust.
              Fuck off.

              • 2 weeks ago
                Anonymous

                >yet you insist on doing low-level stuff with Rust.
                And that is bad because?

              • 2 weeks ago
                Anonymous

                We're arguing in circles, and I suspect that's your intention.

                The thing is, C is actually unsafe, programmers have just become too retarded to use it, and instead of manning up, they're pussying out and outsourcing their dumbness into some supposed inherent safety feature of a new language.
                Their imposing of Rust is a literal dragging down everyone to their level of retardation.

                It's a retarded language, it might rub off on me.

                Look, I don't give a fuck what language you want to code in, but YOU'RE the ones telling ME what language I should use.

              • 2 weeks ago
                Anonymous

                >We're
                I'm not

                Wrong. Nobody has any power over what language you use. Stop being deluded.

                .

              • 2 weeks ago
                Anonymous

                You Rustlets are all the same to me.

              • 2 weeks ago
                Anonymous

                Are we though? Sounds to me like you're a hypocrite who whines about Rust creeping into everything, yet thinks other people have some kind of obligation to use C for everything like a suckless larper.

              • 2 weeks ago
                Anonymous

                >Ok then, go ahead and write device drivers with Javascript.
                I prefer Rust.

              • 2 weeks ago
                Anonymous

                You are not making any sense. Where does JS come into play?

              • 2 weeks ago
                Anonymous

                It doesn't, just like Rust will never succeed in replacing C no matter how hard you shill for it.

              • 2 weeks ago
                Anonymous

                ... what? Rust is already the second language in Linux.
                Now please tell me what's wrong in writing drivers in Rust? Microsoft Edge IoT is already written in Rust.

              • 2 weeks ago
                Anonymous

                https://www.zdnet.com/article/linus-torvalds-on-where-rust-will-fit-into-linux/
                >What does Torvalds make of all this? He's in "the 'wait and see' camp -- I'm interested in the project, but I think it's driven by people who are very excited about Rust, and I want to see how it actually then ends up working in practice."
                >"Personally," Torvalds is "in no way "pushing" for Rust, [but] I'm open to it considering the promised advantages and avoiding some safety pitfalls, but I also know that sometimes promises don't pan out."
                Pre-"intervention" Linus would be calling them idiots on a loop and farting in their general direction, and he's been strongarmed ever since.
                Dark days ahead.

              • 2 weeks ago
                Anonymous

                >Dark days ahead.
                For cniles, yes.

              • 2 weeks ago
                Anonymous

                >I think it's driven by people who are very excited about Rust
                Kek, you gotta give props to Linus' ability to euphemize his insults.

              • 2 weeks ago
                Anonymous

                JS is interpreted and runs on top of an engine written in C++ while rust compiles to LLVM IR
                they are not comparable at all

              • 2 weeks ago
                Anonymous

                It wasn't an argument about the technical aspects of the language, you dishonest dunce.

              • 2 weeks ago
                Anonymous

                What technical arguments do you have against Rust?

              • 2 weeks ago
                Anonymous

                I don't care for Rust too much as it doesn't support a rich enough array of thread safety models. It's a consequence of having been written by people without real embedded or real-time programming experience.
                If they were just working on making it a good language for building desktop applications, that wouldn't be a big downside. But they're arguing that they should get to take over everything that C does, and that's not going to be happy.
                I'm not even sure how to do a data structure with multiple VLAs in a row in Rust. (That layout is weird, but allows for much more efficient memory transfers in an application I maintain - enough that things fit in the real time guarantee - than the usual array-of-structs approach. And yes, it's ugly in C too, but compiles to efficient code.)
                If your response is that I shouldn't want to do that, you're part of the problem and not part of the solution.

              • 2 weeks ago
                Anonymous

                just write another crate to do it, c++ doesn't natively support VLAs either

              • 2 weeks ago
                Anonymous

                >I'm not even sure how to do a data structure with multiple VLAs in a row in Rust.
                More or less the same way you already are, with unsafe code, but now you can encapsulate it behind a safe interface.

              • 2 weeks ago
                Anonymous

                >I'm not the one demanding client-side browser code to be written in C, and yet you insist on doing low-level stuff with Rust.
                That's the purpose of Rust. The purpose of C was writing Space Travel on a PDP-11.

              • 2 weeks ago
                Anonymous

                What technical arguments do you have against Rust?

                >nobody
                You mean the 2 cniles that actually doesn't know programming?

                Cope, seethe and dilate, Rustlets, I'm off to bed now.

              • 2 weeks ago
                Anonymous

                Take meds

              • 2 weeks ago
                Anonymous

                Rent free

      • 2 weeks ago
        Anonymous

        Programmers have always been too retarded to use it.
        https://dl.acm.org/doi/10.1145/96267.96279
        Every single implementation of uniq they tested turned out to segfault if you fed it weird input. Fucking uniq! This is not a complicated program, but not one Unix implementation in 1990 got it right (except perhaps GNU, which they didn't test).

        • 2 weeks ago
          Anonymous

          [log in to view media]

          Probably cause the intern coded it or something.

          • 2 weeks ago
            Anonymous

            >Probably cause the intern coded it or something.
            Probably the same one who made this crap.
            https://github.com/mortdeus/legacy-cc

          • 2 weeks ago
            Anonymous

            Why are you letting the intern write core system utilities?

    • 2 weeks ago
      Anonymous

      Real men use haskell. Not you imperative shit languages that any talking monkey can master.

    • 2 weeks ago
      Anonymous

      >Men take risks by repeating the same easily avoided programming mistakes over and over again for 50 years straight

      The thing is, C is actually unsafe, programmers have just become too retarded to use it, and instead of manning up, they're pussying out and outsourcing their dumbness into some supposed inherent safety feature of a new language.
      Their imposing of Rust is a literal dragging down everyone to their level of retardation.

      Rust didn't invent memory safety. Lisp was created more than 10 years earlier than C

      • 2 weeks ago
        Anonymous

        Lisp is not useful.

      • 2 weeks ago
        Anonymous

        >Lisp was created more than 10 years earlier than C
        And yet, nobody ever thought about every C application with Lisp.

      • 2 weeks ago
        Anonymous

        GC dont count

    • 2 weeks ago
      Anonymous

      meds

  16. 2 weeks ago
    Anonymous

    Why defend the worst part of C++? Just accept that parts of it are "unsafe", use modern tooling to mitigate that, and fuck off. Do you guys actually write code, or are you just CS students who learned about segfaults and Rust an hour ago?

    • 2 weeks ago
      Anonymous

      Segfaults are easy. Problems start when there's no segfaults or observable strange behaviour in most cases.

  17. 2 weeks ago
    Anonymous

    [deleted post]

    impotent rage

  18. 2 weeks ago
    Anonymous

    [deleted post]

    >implicitly announcing a report
    sorry nobody tolerates your shilling

    • 2 weeks ago
      Anonymous

      >nobody
      You mean the 2 cniles that actually doesn't know programming?

      • 2 weeks ago
        Anonymous

        Sure, if you count most of the board as the two """cniles""" inside of your head.

  19. 2 weeks ago
    Anonymous

    [deleted post]

    You did not write my OS or drivers. The one who did is adopting Rust 😉

  20. 2 weeks ago
    Anonymous

    why are there so many threads about c++ and rust?

    • 2 weeks ago
      Anonymous

      Culture war. C++ = right, rust = left. This is not an oversimplification it is actually culture war shit right now.

      For the record I am team rust

      • 2 weeks ago
        Anonymous

        I just love how murricans love to join "teams".

  21. 2 weeks ago
    Anonymous

    [log in to view media]

    [deleted post]

    Same, welcome to the left comrade

  22. 2 weeks ago
    Anonymous

    sticks and stones

  23. 2 weeks ago
    Anonymous

    [log in to view media]

    >not "safe"
    I'LL FUCKING SHOW YOU NOT SAFE KIDDO

Your email address will not be published.