Static Analysis in C++

Static Analysis in C++

The Cherno

4 года назад

80,682 Просмотров

Ссылки и html тэги не поддерживаются


Комментарии:

@lowkienhorng9153
@lowkienhorng9153 - 15.05.2024 10:14

Well maybe it has been 4 years since this video has been uploaded, so its prob outdated ady. However, you could mention a teensy bit more on how to actually make pvs studio run on windows, cause personally i had to do quite a bit of research before even getting to the code part, well its just my opinion so yeah, the video is still helpful, thanks

Ответить
@fireballgfx
@fireballgfx - 30.12.2023 23:29

pvs is free for students and teachers

Ответить
@paulzupan3732
@paulzupan3732 - 23.08.2023 20:41

If only it were free software...

Ответить
@eigenfield
@eigenfield - 12.03.2023 17:55

Thank you. Can you demo any interesting find by PVS-Studio in a multithreaded C/C++ app?

Ответить
@konstantinkonov
@konstantinkonov - 10.03.2023 17:12

Jesus, 5 mins of nonsense speaking before going to a code

Ответить
@avtem
@avtem - 12.01.2023 07:59

Well, yeah it spotted a typo in the copy-pasted loop with y++, but wow, it couldn't even detect an obvious memory leak!

Ответить
@hybridspyda
@hybridspyda - 28.10.2022 20:45

So I used PVS-Studio extension in MVS, and it suggested that I replace my std::vector<std::pair<int, float>> with an std::array instead as the size was known at compile time.
I said, alright, let me do just that... Switching over to use std::array<std::pair<int, float>, 21> now instead gives me an error: "incomplete type is not allowed"... Looking up solutions for similar issues with using an array and pair only says to add more curly brackets, but this doesn't seem to help... Any pointers?

Ответить
@syirogane
@syirogane - 10.09.2022 13:42

Nested for loop bugs... I learned how to use gdb's hardware breakpoints because of a nested for loop bug in the quake source code (a month or two after id released the source code). Specifically, it was in the updating of beams (lightning gun). It took me a few days to figure everything out (programming in Linux was still new to me, gdb very new, and quake was pretty big (I now know it like the back of my hand))

Ответить
@Ferocious_Imbecile
@Ferocious_Imbecile - 28.07.2022 20:29

Gotta say; damn these are enjoyable.

Ответить
@lnx648
@lnx648 - 22.07.2022 18:56

A tip to avoid the classic copy and paste and forgetting the old variable name error... You can just select the lasted portion of code and search and replace text only within the selected portion of text in Visual Studio, or VSCode... And probably many other editors.
Just press Ctrl+F and there is a little button to enable it (probably with a shortcut that I don't remember), it will only highlight the matches inside the selected text so you can be sure... Pretty useful seems like a lot of people don't know about it tho

Ответить
@h.hristov
@h.hristov - 16.07.2022 17:52

PVS Studio do not sell single-user licenses,

Ответить
@Antovolt
@Antovolt - 11.04.2022 15:13

Le frère caché d'Antoine Daniel

Ответить
@bern_stock8946
@bern_stock8946 - 29.03.2022 17:25

where can i get a 5000 line single file c++ code? i need it for static and dynamic analysis practice.

Ответить
@stevesmith7413
@stevesmith7413 - 11.03.2022 00:00

I can tell you have a very clear and organized mind.

Ответить
@AmnesiaPhotography
@AmnesiaPhotography - 06.01.2022 06:03

With how cheap compute is, I think you should be running a spell check and logical analyser. Spelling matters esp for public member functions that you’re defining. I’ve seen this a few times where someone spells the member wrong and this causes issues in dependencies.

Ответить
@webinno
@webinno - 17.12.2021 18:50

Sometimes listening to some "cpp talks", they are always saying "Static Analysis" to be used quite often, I thought it's a programming technique but now some misplaced memories in my brain will find the right places. Thank you!

Ответить
@insu_na
@insu_na - 16.12.2021 20:35

Not C++, but I would never ever write a bash script without shellcheck anymore. It's soooo good.

Ответить
@harikumar-cq1je
@harikumar-cq1je - 01.11.2021 14:52

please also list what are the disadvantages when using PVS tudio

Ответить
@TNothingFree
@TNothingFree - 01.10.2021 22:13

There are many free tools but not so many great tools for VS integration.
I mean, VS has it's own rules for static analysis but I feel it lacks interactive feeling with the user.

Clang tidy and C++ Check are free tools to use as well. (I like C++ Check, it's awesome).

Ответить
@Asdayasman
@Asdayasman - 17.07.2021 22:34

Hold on... Do actual native-speaking adults use spellcheckers? Is that not a meme?

Ответить
@dongwookim6360
@dongwookim6360 - 31.03.2021 05:34

Summary: You need static analysis tool for your program as much as you need spell checker for your document. Here are some example usage of PBS (static analysis tool) for your program.

Ответить
@davidroonie1336
@davidroonie1336 - 23.03.2021 10:28

26 video cuts in first 5 minutes

Ответить
@DrLazyCreature
@DrLazyCreature - 28.02.2021 00:19

Less bugs? How about unit tests? :)

Ответить
@Dosenwerfer
@Dosenwerfer - 15.01.2021 23:00

I am seriously surprised to learn that in the Visual Studio world this is not taken for granted. I'm coming from JetBrains IDEs and they have all of those nice features built-in without question. And a very sophisticated and granular approach to warning levels as well; you can basically customize everything. To see that Visual Studio is only able to do all this nice stuff only by depending on 2 (paid) extensions (Visual Assist and PVS) while at the same time being the most buggy and unstable software I ever had on a computer is pretty sad. Especially considering its age and development time advantage. You'd expect it to be mature, but it is not. At work I am forced to use it and it gets in my way wherever possible. Only after you learn to ignore like 70% of all IntelliSense errors since they are false-positives, your programming experience gets bearable.

Ответить
@mr.anderson5077
@mr.anderson5077 - 18.12.2020 20:57

Charno The GOAT!!!

Ответить
@Hylocichla
@Hylocichla - 11.12.2020 01:19

I wish you had shown how to install PVS Studio. I cannot get it to work because it keeps stating the license is not valid (or has not be activated?).

Ответить
@Stehocke
@Stehocke - 29.11.2020 23:10

angenommen ich nutze VS 2017, was diesen Extension Button im Menü nicht besitzt. Wie starte ich PVS-Studio in Visual Studio nach der Installation. Das Ausführen der exe lässt ja nur ein kleines Infofenster aufgehen. Ist PVS ohne Visual Studio 2019 nutzbar?

Ответить
@MyCiaoatutti
@MyCiaoatutti - 23.09.2020 14:32

Little advice for static analyzer users: they complement each other (e.g., I use Resharper C++ and PVS-Studio together). Also, dynamic analysis is quite critical too! For example, PVS-Studio and Resharper C++ can't detect every memory leak, so you have to do some dynamic analysis to catch them. For example, in Visual Studio, you can expose memory leaks easily using a simple function (_CrtSetDbgFlag ( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF );
There exist static analyzers that can discover every bug: they are called "sound" static analyzers. Polyspace (by Mathworks) uses abstract interpretation to "prove the absence of certain run-time errors in source code for C/C++, and Ada," but it is computationally very expensive

Ответить
@skrya1248
@skrya1248 - 12.08.2020 18:17

Lol, that y was burning my eyes the moment he left it untouched... ><

Ответить
@aliaksei_sala
@aliaksei_sala - 21.06.2020 01:48

What about buffer overflow inside 'for loops' : buffer[x+y*width] where buffer size = width*height.
Can it detect this one?

Ответить
@GeorgeValkov
@GeorgeValkov - 15.06.2020 19:53

Visual Studio comes with built-in static analysis tools: Analyze, Run Code Analysis, On Solution. It would be nice if you make a video comparing them.

Ответить
@at2ectrebuke
@at2ectrebuke - 10.06.2020 22:29

Cherno, huge thanks for this video, not only was it informative, but more importantly it managed to knock my 4 year old out for the night.
Great stuff 👍🏾

Ответить
@madeso
@madeso - 02.06.2020 00:15

It doesn't detect the memory leaks. You can avoid the first error by stop copying code. If you copy because it's too much to type it should probably be refactored instead of copied. The second one can be solved by not using c functions and using string_view/std::string instead. That said, their blog is useful and it's embarrassing how many errors they can find :)

Ответить
@hiren07ec
@hiren07ec - 31.05.2020 16:49

I want video end full music theme...

Ответить
@DestroyItYourself
@DestroyItYourself - 29.05.2020 03:26

Strings are automatically null-terminated, so no need to explicitly add it at the end.

Ответить
@panstromek
@panstromek - 26.05.2020 22:05

This was probably the first brand deal ever that offered something I am actually really interested in. Good job.

Ответить
@glennstormdesign
@glennstormdesign - 24.05.2020 17:36

Can this be used as part of Continuous Integration? (as in, a server runs static analysis?) Because a static analyzer I’m trying out now (cppcheck) is taking a very long time. ‘Seems like a good candidate for CI, no?

Ответить
@MichaelHazell
@MichaelHazell - 14.05.2020 23:54

I'm a little disappointed that you didn't mention clang-tidy, or clangd (which includes clang-tidy) in this video. I get that this was a sponsored video, but I think you should be fair and mention the free and open-source tools here.

Ответить
@rohan_devarc
@rohan_devarc - 14.05.2020 08:04

Good advertisement for PVS studio. Instead you can use clang-static -analyzer

Ответить
@naimasivexo5294
@naimasivexo5294 - 13.05.2020 18:27

how i didn't know u befor e wtf just thx

Ответить
@flyjanabeaali
@flyjanabeaali - 13.05.2020 07:24

1st 4 minutes were so interesting.. so informative 😇

Ответить
@dincerekin
@dincerekin - 13.05.2020 05:38

isnt using "new" in c++ meant to be frowned upon ?

Ответить
@stanislavlarionov1534
@stanislavlarionov1534 - 12.05.2020 12:27

Hey Cherno! Can you make video about cache misses optimisation?

Ответить
@carolsanders9367
@carolsanders9367 - 12.05.2020 08:38

I'm looking for a tool that will better help with syntax errors. Any suggestions?

Ответить
@jeffzheng2355
@jeffzheng2355 - 10.05.2020 19:47

Truly love your cpp series. Could you make some video about cmake?

Ответить
@Kricen
@Kricen - 09.05.2020 23:08

PVS studio doesn't seem to have a single user license. Doesn't matter, I never buy anything if I can't see the price right away.

Ответить
@Gebes
@Gebes - 09.05.2020 22:29

All jetbrains products to that out of the box. They also automatically highlight such mistakes, which saved me lots of headaches in the past years

Ответить
@rafalmichalski4893
@rafalmichalski4893 - 09.05.2020 18:22

Cherno could you explain clang-tigy usage ?

Ответить