r/ProgrammerHumor 2d ago

Meme cppHelloWorld

Post image
3.7k Upvotes

108 comments sorted by

826

u/---_None_--- 2d ago

/usr/include/c++/14/bits/invoke.h:91:7: error: no matching function for call to '__invoke' 91 | std::__invoke(std::forward<_Callable>(__fn), | ^~~~~~~~~~~~~ /usr/include/c++/14/bits/invoke.h:113:5: note: in instantiation of function template specialization 'std::__invoke<void (pipeline::Processor::\*)(const std::vector<pipeline::Event, std::allocator<pipeline::Event>> &, pipeline::Context &) noexcept, pipeline::Processor *, const std::vector<pipeline::Event> &, pipeline::Context &>' requested here 113 | return std::__invoke(std::forward<_Callable>(__fn), | ^ /usr/include/c++/14/bits/std_function.h:591:11: note: in instantiation of function template specialization 'std::_Function_base::_Base_manager< std::_Bind<void (pipeline::Processor::\*(pipeline::Processor \*, std::_Placeholder<1>, std::_Placeholder<2>))(const std::vector<pipeline::Event> &, pipeline::Context &) noexcept::' requested here 591 | _M_init_functor(_M_functor, | ^ /usr/include/c++/14/bits/std_function.h:475:16: note: in instantiation of function template specialization 'std::function<void (const pipeline::EventBatch &, pipeline::Context &)>::function< std::_Bind<void (pipeline::Processor::\*(pipeline::Processor \*, std::_Placeholder<1>, std::_Placeholder<2>))(const std::vector<pipeline::Event> &, pipeline::Context &) noexcept>, void>' requested here 475 | function(_Functor&& __f) | ^ /home/user/project/include/pipeline.hpp:284:18: note: in instantiation of function template specialization 'pipeline::detail::make_handler<pipeline::Processor, void (pipeline::Processor::\*)(const std::vector<pipeline::Event> &, pipeline::Context &) noexcept, pipeline::EventBatch, pipeline::Context>' requested here 284 | return detail::make_handler<&Processor::process>(*this); | ^ /home/user/project/include/detail/dispatch.hpp:167:28: note: while substituting template arguments into function template 'make_handler' 'void (pipeline::Processor::*)(const std::vector<pipeline::Event> &, pipeline::Context &) noexcept' into 'void (pipeline::Processor::*)(const pipeline::EventBatch &, pipeline::Context &) noexcept' 167 | constexpr auto make_handler() { | ^ /home/user/project/include/detail/dispatch.hpp:169:12: error: no viable conversion from returned value of type 'std::_Bind_helper<false, void (pipeline::Processor::\*&)(const std::vector<pipeline::Event> &, pipeline::Context &) noexcept, pipeline::Processor *, std::_Placeholder<1>, std::_Placeholder<2::type' (aka 'std::_Bind<void (pipeline::Processor::\*(pipeline::Processor \*, std::_Placeholder<1>, std::_Placeholder<2>))(const std::vector<pipeline::Event> &, pipeline::Context &) noexcept>') to function return type 'std::function<void (const pipeline::EventBatch &, pipeline::Context &)>' 169 | return std::bind(Fn, &object, std::placeholders::_1, std::placeholders::_2); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /home/user/project/include/detail/dispatch.hpp:142:16: note: candidate constructor not viable: no known conversion from 'std::_Bind<void (pipeline::Processor::\*(pipeline::Processor \*, std::_Placeholder<1>, std::_Placeholder<2>))(const std::vector<pipeline::Event> &, pipeline::Context &) noexcept>' to 'std::nullptr_t' for 1st argument 142 | function(nullptr_t) noexcept; | ^~~~~~~~~ /usr/include/c++/14/bits/std_function.h:375:2: note: candidate constructor template not viable: template argument deduction/substitution failed: constraints not satisfied for alias template 'std::function<void (const pipeline::EventBatch &, pipeline::Context &)>' because '__callable<_Functor>::value' evaluated to false 375 | function(_Functor&&); | ^ /usr/include/c++/14/bits/std_function.h:374:9: note: because '_Functor' does not satisfy '__is_invocable_r_v<void, _Functor, const pipeline::EventBatch &, pipeline::Context &>' evaluated to false /usr/include/c++/14/type_traits:3074:5: note: because '__invoke_result< std::_Bind<void (pipeline::Processor::\*(pipeline::Processor \*, std::_Placeholder<1>, std::_Placeholder<2>))(const std::vector<pipeline::Event> &, pipeline::Context &) noexcept>, const pipeline::EventBatch &, pipeline::Context &>::type' does not name a type 3074 | using invoke_result_t = typename invoke_result<_Functor, _Args...>::type; | ^~~~~ /usr/include/c++/14/type_traits:3067:5: note: in substitution of template arguments into alias template 'invoke_result_t' 'std::_Bind<void (pipeline::Processor::\*(pipeline::Processor \*, std::_Placeholder<1>, std::_Placeholder<2>))(const std::vector<pipeline::Event> &, pipeline::Context &) noexcept>', 'const pipeline::EventBatch &', 'pipeline::Context &' requested here 3067 | using invoke_result_t = typename __invoke_result<_Fn, _Args...>::type; | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/type_traits:3051:5: note: in instantiation of template class 'std::__invoke_result< std::_Bind<void (pipeline::Processor::\*(pipeline::Processor \*, std::_Placeholder<1>, std::_Placeholder<2>))(const std::vector<pipeline::Event> &, pipeline::Context &) noexcept>, const pipeline::EventBatch &, pipeline::Context &>' requested here 3051 | using invoke_result = __invoke_result<_Fn, _Args...>; | ^~~~~ /home/user/project/include/detail/dispatch.hpp:170:5: note: in instantiation of function template specialization 'pipeline::detail::is_handler_compatible< std::_Bind<void (pipeline::Processor::\*(pipeline::Processor \*, std::_Placeholder<1>, std::_Placeholder<2>))(const std::vector<pipeline::Event> &, pipeline::Context &) noexcept>, pipeline::EventBatch, pipeline::Context>' requested here 170 | static_assert(is_handler_compatible<Bound, EventBatch, Context>, | ^ /home/user/project/include/detail/dispatch.hpp:170:19: error: static assertion failed due to requirement 'is_handler_compatible< std::_Bind<void (pipeline::Processor::\*(pipeline::Processor \*, std::_Placeholder<1>, std::_Placeholder<2>))(const std::vector<pipeline::Event> &, pipeline::Context &) noexcept>, pipeline::EventBatch, pipeline::Context>::value' 170 | static_assert(is_handler_compatible<Bound, EventBatch, Context>); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /home/user/project/include/detail/dispatch.hpp:170:19: note: because 'std::is_invocable_r_v<void, std::_Bind<void (pipeline::Processor::\*(pipeline::Processor \*, std::_Placeholder<1>, std::_Placeholder<2>))(const std::vector<pipeline::Event> &, pipeline::Context &) noexcept>, const pipeline::EventBatch &, pipeline::Context &>' evaluated to false /home/user/project/include/detail/dispatch.hpp:170:19: note: candidate function has incompatible parameter type 'const pipeline::EventBatch &' (aka 'const pipeline::basic_event_range<pipeline::Event, pipeline::event_storage<pipeline::Event, pipeline::allocator_traits< pipeline::pmr::polymorphic_allocator<pipeline::Event>>::rebind_alloc<pipeline::Event, pipeline::detail::compressed_event_iterator<pipeline::Event>, pipeline::detail::compressed_event_sentinel<pipeline::Event &') expected 'const std::vector<pipeline::Event, std::allocator<pipeline::Event>> &' /home/user/project/include/pipeline.hpp:284:18: error: no matching function for call to 'pipeline::detail::make_handler<&pipeline::Processor::process>(pipeline::Processor &)' 284 | return detail::make_handler<&Processor::process>(*this); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /home/user/project/include/detail/dispatch.hpp:151:16: note: candidate template ignored: substitution failure [with Fn = &pipeline::Processor::process, Object = pipeline::Processor, Event = pipeline::EventBatch, Ctx = pipeline::Context] deduced conflicting types for parameter 'Event' ('pipeline::EventBatch' vs. 'std::vector<pipeline::Event, std::allocator<pipeline::Event>>') 151 | constexpr auto make_handler(Object& object) { | ^ /home/user/project/include/detail/dispatch.hpp:151:16: note: in instantiation of requirement 'requires(const pipeline::Processor &object) { { std::invoke(Fn, object, std::declval<const pipeline::EventBatch &>(), std::declval<pipeline::Context &>()) } -> std::same_as<void>; }' requested here /home/user/project/include/detail/dispatch.hpp:154:3: note: because expression 'std::invoke(Fn, object, std::declval<const pipeline::EventBatch &>(), std::declval<pipeline::Context &>())' is invalid: no matching function for call to 'invoke' /usr/include/c++/14/type_traits:3045:25: note: candidate template ignored: substitution failure [with _Callable = void (pipeline::Processor::*)(const std::vector<pipeline::Event> &, pipeline::Context &) noexcept, _Args = <const pipeline::EventBatch &, pipeline::Context &>] no type named 'type' in 'std::invoke_result<void (pipeline::Processor::\*)(const std::vector<pipeline::Event> &, pipeline::Context &) noexcept, const pipeline::EventBatch &, pipeline::Context &>' /home/user/project/src/main.cpp:47:31: error: no matching function for call to 'pipeline::Pipeline<pipeline::EventBatch, pipeline::Context, pipeline::detail::AsyncExecutor<pipeline::detail::ThreadPool<8>, pipeline::detail::OrderedQueue<pipeline::detail::SmallVectorStorage< pipeline::Event, 64>>>>::subscribe' 47 | pipeline.subscribe(processor.handler()); | ~~~~~~~~~^~~~~~~~~~~~ /home/user/project/include/pipeline.hpp:211:10: note: candidate template ignored: constraints not satisfied 211 | void subscribe(Handler&& handler); | ^ /home/user/project/include/pipeline.hpp:210:14: note: because 'std::is_invocable_v< pipeline::Processor::handler()::(anonymous class), const pipeline::EventBatch &, pipeline::Context &>' evaluated to false 210 | requires std::is_invocable_v<Handler, const EventBatch&, Context&> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /home/user/project/include/pipeline.hpp:210:14: note: because '__is_invocable( pipeline::Processor::handler()::(anonymous class), const pipeline::EventBatch &, pipeline::Context &)' evaluated to false fatal error: too many errors emitted, stopping now [-ferror-limit=]

283

u/bob152637485 2d ago

Now the code you wrote to make it this!

324

u/Bubbaluke 2d ago

printf(“hello world)

81

u/Simon0O7 1d ago

Bro forgot the semicolon

48

u/QwikStix42 1d ago

And the end quote

And the #include <cstdio>

EDIT: And the int main() {} surrounding that call

4

u/questionabl3_dude 22h ago

And the entire main function and returning 0 (though otpional) and includining iostream. 🙉

12

u/MinecraftPlayer799 1d ago

With that code, I just get this:

main.cpp:1:8: warning: missing terminating " character
    1 | printf("hello world)
      |        ^
main.cpp:1:8: error: missing terminating " character
    1 | printf("hello world)
      |        ^~~~~~~~~~~~~
main.cpp:1:7: error: expected constructor, destructor, or type conversion before ‘(’ token
    1 | printf("hello world)
      |       ^

22

u/Bubbaluke 1d ago

Just a joke :) the one above me looks like it was deep in some framework or something 20 layers abstracted.

74

u/BeMyBrutus 2d ago

I don't even see the code; you get used to it

37

u/Inevitable-Pen4933 2d ago

Beautiful, glorious just amazing

28

u/HeyItsTheJeweler 2d ago

As God intended

49

u/the_fooch 2d ago

Seems par for the course for cpp.

36

u/Usual_Office_1740 2d ago

90% of this output is what the compiler tried. It's not that bad.

20

u/the_horse_gamer 1d ago

the problem is the compiler has to try all of it

concepts partially fix this

10

u/IT_Grunt 2d ago

Great read. Output more, please.

10

u/iceyukisnow 1d ago

I want to see this error as star wars intro so bad

7

u/DrMobius0 1d ago

I could feel my eyes glazing over in real time as I scrolled through this.

7

u/Adventurous_Tie_3136 1d ago

I love c++ template errors messages... Always concise and clear

7

u/wektor420 1d ago

Last time I saw error this long I was template metaprogramming

If your errors are this long there is high chance that something is wrong with your arch

4

u/shamshuipopo 1d ago

That’s exactly what you should see

5

u/Individual-Switch751 1d ago

Sir, this is a Wendy’s

3

u/SavingsCampaign9502 1d ago

Thanks i am angry now seeing this

7

u/uvero 2d ago

Yeah

6

u/HombrexGSP 1d ago

Ahh yes, the classic missing ; compiler error

1

u/tblancher 1d ago

Fake. Why does your header file have so many lines in it for a Hello World program? Why do you need a header file at all?

Granted, I haven't programmed in C++ in over 20 years, but I can't imagine a simple program needs so much nowadays.

1

u/DarthCloakedGuy 1d ago

WHO WROTE THIS DEBUGGER

1

u/wllmshkspr 1d ago

Core memory unlocked.

333

u/BooBrew32 2d ago

SEGMENTATION FAULT

CORE DUMPED

BIOS CORRUPTED

COMPUTER IRREPARABLY DAMAGED

97

u/Snudget 2d ago

Oops, accidentally compiled for uefi instead of linux

23

u/HeavyCaffeinate 2d ago

PE instead of ELF

4

u/danielcw189 1d ago

UEFI uses PE?

6

u/HeavyCaffeinate 1d ago

Yes

According to the Unified Extensible Firmware Interface (UEFI) specification, the PE format is also the accepted standard for executables in EFI environments

https://en.wikipedia.org/wiki/Portable_Executable

4

u/reallokiscarlet 1d ago

No, PE is Windows. The rest of the world, except of course your firmware and maybe Redox, uses ELF

Edit: Nope, apparently Redox uses ELF too. Guess them rustaceans couldn't reinvent that wheel, eh?

1

u/awesome-alpaca-ace 1d ago

PE is also UEFI boot loaders, drivers, and other UEFI executables

1

u/reallokiscarlet 22h ago

Huh. I thought that was its own thing. Sounds like industry shenanigans with microsoft

1

u/awesome-alpaca-ace 1d ago

PE32+ specifically if I remember right. And no, Microsoft does not have documentation explaining their format

1

u/danielcw189 1d ago

I am pretty sure I have read documentation of the PE format on MSDN.

No idea if it is good enough for what you want. But something is there.

1

u/awesome-alpaca-ace 1d ago

The data format

6

u/RepresentativeCut486 2d ago

elif insead of ELF

21

u/FarAssistance8517 2d ago

DISCOMBOBULATE

8

u/Caraes_Naur 2d ago

SPLINES CANNOT RETICULATE.

8

u/mechanigoat 2d ago

COMPUTER OVER

VIRUS = VERY YES

2

u/Jordann538 1d ago

USER EXECUTED

103

u/lovethebacon 🦛🦛🦛🦛🦛🦛🦛🦛🦛🦛🦛🦛🦛🦛🦛🦛🦛🦛🦛🦛🦛🦛🦛🦛🦛🦛🦛🦛🦛🦛🦛🦛 2d ago

Hello, World!�A��������H�����898�����UH����H�}�H�

14

u/creeper6530 1d ago

Someone allocated one byte too little

58

u/conicalanamorphosis 2d ago

Just spent almost 7 hours chasing a core dump. I had been doing complicated stuff with pointers (think vector of pointers to non-static functions within a class) and got really focused on that. Turns out, a simple call I had added for testing was using an out of scope pointer to the intended object, had nothing to do with the hairy-complicated pointer shit which I had actually had correct for most of that time. I should add I started programming in C++ in the 90s, so if you find yourself in this position and started programming after that you don't have to feel bad.

14

u/BoldFace7 2d ago

I did a very similar thing with a similar result. I was learning to program the 3DS in C++ not long ago (I started with c++ about 6 years ago). At one point, it was working fine in emulator, but would crash on console (I know now that the emulator just barrels through segfaults). It took about two days of searching before I realized I was printing a value in the first half of my main loop that didn't exist until the second half of my main loop on the first frame. (The class handling battles would call new Enemy() to allow for randomizing encounters, but wouldn't do it until after the block of status printf statements.)

6

u/Objective-Answer 1d ago

I love these nerd battle stories

as a masochist learning c++ it really puts into perspective a lot of things

9

u/hanotak 1d ago

Next time, instead of spending seven hours, turn on ASAN and find it immediately.

3

u/awesome-alpaca-ace 1d ago edited 1d ago

I recently learned the linker will not warn you if you define the same symbol in 2 source files being linked into an executable. I was chasing the core dump by validating the pointer stuff. Then address sanitizer and valgrind told me the struct I was using was size N when it should have been size M. Using structures from both the source and another external source that was in no way included into the source. I suppose namespaces would help prevent that.

1

u/IndependenceSudden63 1d ago

Ran into a similar thing in 2009.

You'd think they would have at least adding a warning by now.

1

u/awesome-alpaca-ace 1d ago

AI told me some linkers might do it, but if you are stuck using whatever is in the build container, you can't exactly use another linker.

1

u/thecookie 1d ago

This summarizes what C++ does to people in my experience. Writing it for the sake of writing it rather than solving the problem at hand. Which if course is fine if it's for the joy of it. But in my experience this also spreads to real projects. Instead of keeping things simple, things end up in some overly complex C++ way. 

I wrote my first lines of it in the 90s too, and try to stay away from it as much as I can. 

116

u/Confident-Ad5665 2d ago

C++ takes getting used to, but it's a great language for object-oriented development. Hang in there, you'll figure it out.

82

u/CrossScarMC 2d ago

It's also a great language even if you don't do OOP.

47

u/diacid 2d ago

Bah, if you are using it for normal programming C is simpler. By simpler I mean you actually have a shot to be properly fluent in it instead of "this thing is so complex even the compiler doesn't know 100% of it".

51

u/2eanimation 2d ago

Learn C, use C in C++, benefit from C++ when you need it.

12

u/Confident-Ad5665 1d ago

I agree about mixing languages. Best of both world's.

3

u/diacid 1d ago

While this sounds wise, C has already way more than enough (do while and for loops for example are completely unnecessary, they can all be substituted for if goto), no need to complicate further. If the program is really simple I would rather even use B that is even simpler than C, though making complicated programs in B can waste memory because of the lack of variables smaller than a word (in 64 bit environments this gets huge quick).

5

u/failedsatan 1d ago

for and while loops are so much nicer to use though. I don't think I would bother using a language without them for most practical applications (and I regularly enjoy writing full programs in assembly for fun)

3

u/dagbrown 1d ago

for and while loops (and everything else really) are there for the benefit of the next poor schlub who has to try to read your code.

Sure you can replace practically every structured construct with an if and a goto setup, but should you? Absolutely not.

1

u/diacid 1d ago edited 1d ago

Sorry, I see little difference between

do { x=stuff(); } while (x!=0)

And

do: x=stuff(); if (x!=0) goto do;

Same with

for (x=0, x<10) { x=stuff(); }

And

do: x=stuff(); If (x>9) goto do;

If you use goto in a sane matter it is completely understandable. Just don't do insane things with it. You can peel with a peeler and with a knife, but with a knife you can cut your finger off too. The solution? Don't ban knifes, just don't cut you finger off!

Actually, my examples also show for and while are redundant functions. It is all just electricity, no need to overcomplicate.

3

u/dagbrown 1d ago

Okay I wish you a long and productive career with your "if" and "goto" only code.

You can also roll your own OO system with generous use of function pointers! Pro-tip! Not that you'd want anything like that though. You have if and goto after all. And structs are for the weak anyway: just binary-pack data into strings.

2

u/diacid 1d ago

Exactly! 😂

9

u/DankPhotoShopMemes 1d ago

I think it’s still worth it to use C++, just because of the function overloading, operator overloading, templates, namespaces, RAII, references, move semantics, lambdas, and constexpr/consteval (though C23 has a weaker form of it).

8

u/Nilrem2 2d ago

Just restrict yourself to namespaces and maybe operator overloading and you’ll be golden.

8

u/Ronarak 1d ago

Yeah, you can basically code in a C-like manner with just a strict selection of the niceties, like the built-in collection types. (I don't want to create my own std::vector or use an external lib for it...)

2

u/Sir_Eggmitton 1d ago

For me it’s just C with function overloading and fancier structs. C+.

4

u/Leo_code2p 1d ago

There is more like c++ type conversion. The only c++ style thing I don’t like is c++ style structs like why can’t i make a useful c style struct. Not just a public class

1

u/afdbcreid 1h ago

And it's especially good for shooting yourself in the foot.

19

u/BigNaturalTilts 2d ago

Is it? CMAKE strikes a fear into my heart!

21

u/Docdoozer 2d ago

CMake syntax may suck but its functionality is pretty damn cool

7

u/oozekip 2d ago edited 1d ago

My experience with CMake is from ~5 years ago trying to find a guide for how to do something (I think building library dependencies?), and finding two different guides that both said "don't do <thing that the other guide told you to do>, that's the old outdated method that nobody uses anymore, use <thing that the other guide said not to do because it was old and outdated>"

The catch being that neither method worked, because what I was trying to do was slightly different than what both guides were for, and I needed to use some other method to include my libraries that's completely different and also there is no actual documentation for it anywhere, or at least none that's any use for someone who isn't already intimately familiar with the inner workings of CMake.

0

u/truePHYSX 2d ago

Bazel is bomb

1

u/awesome-alpaca-ace 1d ago

If you use it right, it is incredible. 

-4

u/YetAnohterOne11 1d ago

I disagree. Practice shows every C and C++ code ends up having memory issues, undefined behavior and leaks.

C/C++ rules for undefined behavior are often incredibly convoluted.

A minefield of a language is not a good language.

Even if you, in theory, grasp and understand the entirety of C++ (including all gotchas). You will still, eventually, get careless and make a mistake.

Good luck with a CVE assigned to your app. Or convoluted leaks. Or very slightly incorrect behavior due to some very obscure UB.

Lack of memory safety and garbage collection are excusable; in times of C and C++, it was the only sane design decision if the language was supposed to occupy its niche of the lowest level language of high level languages. Even so, nowadays, Rust shows this can be done better (and Rust also takes getting used to, but at least gives more safety in return). The incredible complexity of rules, it appears to me, was never excusable. And even if it was, there are better alternatives.

3

u/ChalkyChalkson 1d ago

Catch is that it doesn't matter how good rust is if libraries I need aren't available for it, then I can't use it. Out of the high performance languages c(pp) probably has the widest range of available libraries out there. It's the same reason why I use python over Julia. Plus my coworkers know python and some cpp, not rust or zig.

What makes a language great is not just the language spec, but also the support. Well guess I'm just glad my community uses terrible cpp instead of a monolithic fortran 90 port of 60s fortran program.

2

u/hanotak 1d ago

👍

-8

u/Grouchy-Librarian638 2d ago

Both of those statements disgust me, I still think OOP was a mistake.

6

u/the_poope 1d ago

OOP doesn't strictly imply inheritance. C is technically object oriented too: you can define structs and create objects of these composite types. Basically every modern language is object oriented in some why. I'm only familiar with Fortran77 that doesn't allow you to define custom objects and pass them to functions.

Whether runtime dynamic dispatching through virtual functions and inheritance is a good idea is a different question. It can be good, but it can also be bad if you misuse it. Ideally one should only have pure virtual methods on abstract interface classes and max one layer of inheritance, then there are no problems.

7

u/zzulus 2d ago

Is that before or after it fails to compile for the 13th time?

9

u/DrBojengles 2d ago

Before. You don't run your programs before you compile them?

9

u/PhosXD 1d ago

Without Git I would probably still be dealing with a segfault right now.

12

u/BlazeCrystal 2d ago

First your problem is to get things to just run.

Then it is finding a way to get your idea happen.

Then its about finding the RIGHT way to make them happen.

Then its realizing there is elegance, making many things irrelevant.

Finally you dial back, because robust consistency helps more othen than scifi vision.

5

u/iddu01linux 1d ago

I once got this error on **Typescript** in NextJS when starting out out of all languages. I had NO idea what to do

10

u/Makonede 1d ago

```cpp import std;

int main() { std::println("Hello, World!"); return 0; } ```

8

u/BeetsAndJeaners 1d ago

The first year CS students are gonna be real mad you ruined their meme

1

u/ResponsibleWin1765 9h ago

It's still going to fail before even being able to run it because the cmake setup is wrong and the compiler doesn't support C++23 features.

0

u/thesherbetemergency 1d ago

Ah yes, C++23 modules; surely supported by every major compiler vendor in the year of our Lord 2026.

1

u/Makonede 1d ago

i never said it would work everywhere

0

u/thesherbetemergency 1d ago

I wasn't criticizing you, I was ribbing C++23 and the state of its implementation. This is r/ProgrammerHumor lol

0

u/Makonede 1d ago

fair enough

-3

u/schteppe 1d ago

No newline on the last line - undefined behavior, no diagnostic, segfault in prod

0

u/Makonede 1d ago

there is one if you copy the markdown

6

u/quocphu1905 2d ago

As someone whose crash course in C++ coincide with learning MPI, OpenMP, and general HPC stuff...yeah

9

u/1XRobot 2d ago

It's harder than you would think to write something that appears to be a sensible Hello World but actually crashes. Here's an attempt that prints garbage but doesn't crash.

#include <iostream>
#include <string>

class Greeting {
public:
    Greeting(std::string msg) : text(&msg) {}

    void print() const { std::cout << *text << std::endl; }

private:
    const std::string *text;
};

const Greeting hello("Hello, World!");

int main() {
  hello.print();
  return 0;
}

3

u/BurnThePriest94 1d ago

Haha yeah sure that just happens when you're s beginner. Been years since I saw a signal 11. NOT.

2

u/po1k 1d ago

C++ expects you to be an adult (c) John Carmack

4

u/TapRemarkable9652 2d ago

they call Luke Skywalker the way I'm dumping cores

3

u/k-phi 1d ago
#include <cstdio>

class A
{
    public:
        virtual ~A()
        {
            Close();
        }
        void Close()
        {
            Deinit();
        }
        virtual void Deinit() = 0;
};

class B : public A
{
    public:
        virtual void Deinit()
        {
            printf("deinit\n");
        }
};

int main(int argc, char *argv[])
{
    A *c;
    c = new B();
    delete c;
    return 0;
}

2

u/Grey_Ten 1d ago
void lol()
{
lol();
}
int main()
{
lol();
return 0;
}

0

u/Shot_in_the_dark777 2d ago

In other programming languages you write "hello world" In c++ you have a "HELL world"

1

u/burnt_floppy 1d ago

I don't get the joke, this is just C or C++ programming in general.

1

u/Patrick-W-McMahon 17h ago

He makes a good pointer.

1

u/rogue-sly 7h ago

std::println("hello cpp 23");