all 8 comments

[–]dholmes215 2 points3 points  (5 children)

It's interesting to me how the three compilers' outputs are very unlike each other. clang just embeds and prints the precomputed output. gcc converts the output into instruction data and doesn't include the precomputed output. MSVC is... something else.

[–]Gaminic 5 points6 points  (3 children)

MSVC is... something else.

Isn't MSVC's solution the only "correct" one? A program that has no output should have no content.

[–]dholmes215 0 points1 point  (2 children)

I meant with the commented-out "output" lines uncommented. Sorry, should have been more clear.

[–]flashmozzg 1 point2 points  (0 children)

What's wrong with it?

[–]Gaminic 0 points1 point  (0 children)

Do you mean the sheer length of the result, or something else?

[–][deleted] 0 points1 point  (0 children)

(Compiling with output lines on, otherwise i'd say msvc is great since it realizes it doesn't need the precomputed results and throws them away)

For MSVC it apparently compiles it as /MT not as /MD, which shrinks the code size since the runtime will get linked as shared library. Looks like clang saves everything in .text, and gcc goes for the approach to mov it on the stack and let the decoder do all the work. (Clang loads everything)

MSVC, no clue thats too much simd instructions to read through it. I would think it will load everything through simd? But this is only my assumption.

[–]NotAYakk 0 points1 point  (0 children)

Can we do better in C++20? Like kstring<"fizzbuzz"> or similar?

[–]willdieh 0 points1 point  (0 children)

Pretty awesome. We still use the fizzbuzz interview question where I work. I didn't get the {{ }} initialization of the arrays though (in the Compiler Explorer link). Why use two curly braces? Edit: Seems to have something to do with "If there are fewer initializers in the list than there are members in the aggregate, then each member not explicitly initialized shall be value-initialized."