Dima
like static/fixed arrays?
BinaryByter
The idea is when you need that memory only at compile time
think about what you just proposed for a second
Francisco
think about what you just proposed for a second
Maybe I didn't explain myself well. I'll look for that info later
Anonymous
Nobody knows this in detail?*
Anonymous
Welcome JoHnY! Please read the pinned message 🙂
Anonymous
G
Stefan
and the compiler is called cfront
Anonymous
Instead of g++?
Stefan
yeah
Stefan
At the beginning, constexpr functions could only be recursive. Now you can define functions as constexpr with any code inside
template metaprogramming came before constexpr and is still prevalent for example constexpr auto foo(auto bar) -> T how do you deduce it
Stefan
i asked bjrane himself for that...i think im quite stupid at the time
Stefan
What is so dangerous about C functions such as fgets or fflush?
actually they're not gets getc however they do
olli
think about what you just proposed for a second
Containers might be useful in `constexpr`contexts as well, but therefore you would need to have "dynamic memory at compile time" IIRC this has been initially proposed in 2017
Anonymous
Stefan
Why is gets and getc dangerous?
buffer overflow from stdin
Anonymous
buffer overflow from stdin
What can I search for or what can I do to learn the specifics on how it was remedied with scanf, and how to perform the buffer overflow?
Stefan
What can I search for or what can I do to learn the specifics on how it was remedied with scanf, and how to perform the buffer overflow?
you can set the parse size for scanf but most of the time people didnt realize that so its your fault
Stefan
while gets and getc
Stefan
Anonymous
Can I recover my deleted data from my laptop??????
klimi
:33
klimi
Oh this pack is bigger
Anonymous
If I write const int a; int *p =&a; Is this wrong..?
Stefan
But undefined behavior
Stefan
UB is right and wrong at the same time
Stefan
because this const modifier isn’t really constant
Stefan
It just tells the compiler that this variable shouldn’t be reassigned
Stefan
Aka immutable
Stefan
Using this information, the compiler can perform real constant propagation optimisation
Stefan
See the three shits of javascript: let const var
klimi
Hey dude, do you have permission?
klimi
I mean if you don't answer within 5 mins I'll delete that and warn you for not obeying rules
Ariana
/warn ad for a crappy event
Anonymous
that message has link different
Anonymous
yes we have the permission
Stefan
uh, no?
Stefan
https://godbolt.org/z/ss9hEc
Stefan
[Meme] Learning C, thought this little tidbit was hilarious https://redd.it/anerd8 by @programmer_humor
Stefan
Stefan
But undefined behavior
Stefan
UB is right and wrong at the same time
Stefan
because this const modifier isn’t really constant
Stefan
so basically saying, ub is nondeterministic
Stefan
anything could happen, philosophical absurdity
Stefan
people used to call it nasal demon
Stefan
then why you could assign a mutable value into "const"
Stefan
char *foo = "bar" this is actually undefined
Stefan
assigning a const char[4] to char*
Stefan
under pointer decay, const char[4] -> const char * -> char *
Stefan
immutable -> mutable mutable -> immutable
Stefan
what is this, insanity?
Stefan
Why this is undefined?
cause you make "constant" stuff "modifiable"
Anonymous
cause you make "constant" stuff "modifiable"
If you would change the value of foo again, this would be undefined. But just init a C-style string with "bar" isnt undefined in C.
Dima
/ban no
Stefan
alright, i will stop the flamewar here, actually this is ambiguous
Stefan
under c, ub under c++, plain out compilation error
Stefan
If I write const int a; int *p =&a; Is this wrong..?
but since this snippet is valid and invalid in both c and c++
Stefan
we dont have an answer, pigs can fly
Stefan
would you mind using visual studio to check the type of the string literal, it will exactly show you const char[strlen(this) + 1]
Stefan
https://en.cppreference.com/w/cpp/language/string_literal
Stefan
you be getting a pointer, that's the consequence of array decaying
Stefan
well, you could see this as a terrific past of c++ trying to smoosh with c
Stefan
then isn't it contradictory? "constant"/immutable things can be made mutable
Stefan
why is this not?
Stefan
error: invalid conversion from 'const int*' to 'int*'
Stefan
sounds paradoxic to me
Ludovic 'Archivist'
Stefan
I call it dragons
uh, runescape?
Ludovic 'Archivist'
Ludovic 'Archivist'
Just do you want a dragon in your server room?
Stefan
Mmmh? No
dragon slayer😂
Ludovic 'Archivist'
Probably not
Ludovic 'Archivist'
And if you want a dragon, you want a tamed one
Ludovic 'Archivist'
One that you can put in a wheel to generate power