Nurlan
I should learn deeper into this
Vlad
UB sanitizer caught it
Vlad
Also stack corruption
Vlad
But sadly no out of bounds for std::vector
Vlad
Although you could get a habit of having .at() on debug
aura_
Can I learn C++ leaving C ?
aura_
Anybody suggest?
Pavel
Although you could get a habit of having .at() on debug
You mean? int a = arr #ifdef DEBUG .at( #else [ #endif 6 #ifdef DEBUG ) #else ] #endif ; 😂
四只老虎化黃油
Of course learn C++ as a better C
Vlad
No
Also you may throw some boundaries checking asserts just in case
Pavel
Can I learn C++ leaving C ?
Yes, I've learnt C++ without prior knowledge of C (and still don't know much of C after 7 years working with C++, and don't need to).
aura_
Online or with books ?
Anonymous
Can I learn C++ leaving C ?
yes. they are unrelated (but everything you learn helps)
aura_
yes. they are unrelated (but everything you learn helps)
I want to learn about security which languages with help
Pavel
Form where u have learned ?
I've started from shitty books like "C++ for hackers" 🤦‍♂ There wasn't much choice back then (I didn't have good internet access), right now there are plenty of good books. Other guys can give good suggestions, also there were notes about books somewhere in this chat bots.
aura_
no idea sorry
No problem
Kenny
Form where u have learned ?
there's a lot of online tutorials, i use sometimes geekforgeeks or cppreference
aura_
Thnx all for your help
Anonymous
Thnx all for your help
i would say start with Lippman's book
Anonymous
Can u provide link ?
amazon link? sure. library genesis? no.
aura_
Ohk I will buy .
aura_
😊
Anonymous
Ohk I will buy .
https://www.amazon.com/dp/0321714113/
aura_
Thnx you 👍
Ajay
Debugger is pretty the same. I've just run gdb a.out and thats it
@chandradeepdey Actually, I was just relying on lldb a.out to work for it but seems like that's not the case as was described in the comment I'm replying. BTW, apart from the -fsanitize=address flag, what other flags should I turn on to make it quick to debug the code rather than the debugger skipping it?
Arseny
Exactly
Arseny
(don't forget to run it after start)
Ajay
Yeah it catches it. but why didn't it catch for queue.pop()? Any reason?
Arseny
after start?
Yep $ gdb a.out (gdb) r
Ajay
What exactly should it catch in that case?
I'm popping an empty queue, so may be that's an exception i guess?
Arseny
isn't there any provision to catch it?
Queue is an adaptor, which can be implemented based on deque. Than pop will be implemented using deque::pop_front(), which is no throwing method. Calling it on empty container is UB.
Arseny
ok so debuggers don't catch UB that's why?
UB cannot be catched by debuggers. You can try using ubsan
Ajay
UB cannot be catched by debuggers. You can try using ubsan
Just to ask, do you recommend to use any flags to catch something that the debugger might not catch?
Wojak
Then there will be no need to say popfront because it's in the defination of queue to use pop from front and push from rear.. You are explaining dequeue, there is need to define pop_front() and pop_back() and push_front() and push_back() violating the law of normal queue (ie. Front can be used for pop and push both an rear can be used for pop and push both in dequeue)
Anonymous
i would sugget watching Jason Turner's playlist on intro to C++ tools
Ajay
read the sanitizer manuals. you cannot use them all at once
Just to confirm, you mean many variants of -fsantizer-... cannot be used together. Right?
Ajay
Caught what?
array index out of bounds. OH that's UB. That's why. Right?
Ajay
Yep
👍
Arseny
Compile it with ubsan, run and enjoy
Ajay
Compile it with ubsan, run and enjoy
haha, sure. Thanx for ubsan !!
Arseny
You're welcome
Nils
How do I increment an lvalues pointer destination?
Nils
Wtf my client somehow rejoined
Jesvi
/rules
Anonymous
Hi guys
Andrew
Hello guys
Andrew
I have question regarding c language I'm getting a stack smashing
Vlad
How do I increment an lvalues pointer destination?
Do you mean address itself or the value at that address?
Nils
Value at that adress
Nils
But after having done that I need to increass the pointer by 7, in the same line
Andrew
void main (){ int seq[] = {}; int flag = 0; while(flag < 5){ printf("Write a whole number \n"); scanf("%d",&seq[flag]); printf("%d \n" , seq[flag]); printf("This is flag : %d \n", flag); flag++; } } why am I getting stack smashing detected. I'm sorry I'm newbie.
Nils
Like &(--(*p)) + 7