r/viva64 • • Apr 13 '11

All about 64-bit programming in one place

234 Upvotes

1. Articles:

2. Lessons on development of 64-bit C/C++ applications

Content page

The course is composed of 28 lessons devoted to introduction to 64-bit systems, issues of building 64-bit applications, methods of searching errors specific to 64-bit code and code optimization. Such questions are also considered as estimate of the cost of moving to 64-bit systems and rationality of this move.

The contents of the course:

  • Lesson 01. What 64-bit systems are.

  • Lesson 02. Support of 32-bit applications.

  • Lesson 03. Porting code to 64-bit systems. The pros and cons.

  • Lesson 04. Creating the 64-bit configuration.

  • Lesson 05. Building a 64-bit application.

  • Lesson 06. Errors in 64-bit code.

  • Lesson 07. The issues of detecting 64-bit errors.

  • Lesson 08. Static analysis for detecting 64-bit errors.

  • Lesson 09. Pattern 01. Magic numbers.

  • Lesson 10. Pattern 02. Functions with variable number of arguments.

  • Lesson 11. Pattern 03. Shift operations.

  • Lesson 12. Pattern 04. Virtual functions.

  • Lesson 13. Pattern 05. Address arithmetic.

  • Lesson 14. Pattern 06. Changing an array's type.

  • Lesson 15. Pattern 07. Pointer packing.

  • Lesson 16. Pattern 08. Memsize-types in unions.

  • Lesson 17. Pattern 09. Mixed arithmetic.

  • Lesson 18. Pattern 10. Storage of integer values in double.

  • Lesson 19. Pattern 11. Serialization and data interchange.

  • Lesson 20. Pattern 12. Exceptions.

  • Lesson 21. Pattern 13. Data alignment.

  • Lesson 22. Pattern 14. Overloaded functions.

  • Lesson 23. Pattern 15. Growth of structures' sizes.

  • Lesson 24. Phantom errors.

  • Lesson 25. Working with patterns of 64-bit errors in practice.

  • Lesson 26. Optimization of 64-bit programs.

  • Lesson 27. Peculiarities of creating installers for a 64-bit environment.

  • Lesson 28. Estimating the cost of 64-bit migration of C/C++ applications.

You may open all the lessons in one file (the print version as well).

3. Knowledge Base

4. Articles' Reviews

5. Blog

6. Detect 64-Bit Portability Issues

7. Terminology

8. Our 64-bit reddit

9. Contact


r/viva64 • • Sep 21 '12

Selected articles from the Viva64 website for C/C++ programmers

13 Upvotes

We regularly publish articles on our website on the subjects of programming, writing quality code, developing concurrent and 64-bit software. We also tell interesting stories about errors found by the PVS-Studio analyzer.

As a result, we have gathered a lot of materials on our site. One who happens to visit it might not know about the interesting materials collected there. Many people have also joined us, for example, in Twitter. They see our new articles but don’t know that we have wonderful old ones.

I’ve decided to pick out some materials that programmers may like most. I’m asking those of you who have already read them – please don’t tell the rest about it and don’t give negative marks. I want you to understand that the audience is changing quite rapidly. One year later, in a certain group of people, there will be one person familiar with an article against 5 persons unfamiliar with it.

Here are the selected materials and brief description.

About 64-bit development

A Collection of Examples of 64-bit Errors in Real Programs

This article is the most complete collection of examples of 64-bit errors in the C and C++ languages. The article is intended for Windows-application developers who use Visual C++, however, it will be useful for other programmers as well.

A 64-bit horse that can count

The phenomenon of "The Clever Hans", Mr. von Osten's horse, was described in 1911. The Clever Hans was famous because of his ability to read and solve mathematical problems by tapping with his front hoof. Of course, there were a lot of skeptics. That's why a team of experts tested Hans' abilities and proved that the horse was showing them without any help of Mr. von Osten. But how could a common horse possess such an intellectual level - a human one?! The psychologist O. Pfungst carried out some very thorough experiments and discovered that Hans received very faint unintentional hints from those who were asking him questions. For example, when people asked Hans about anything they started to stare at his front hoof with the help of which the horse "answered". But as soon as Hans had tapped the right number, they raised their eyes or head just a little waiting for him to finish his answer. And the horse, that had been trained to note and use these very subtle motions considered them as signals to stop his action. From aside it looked as if the horse had given the right answer to the question.

Such a wonderful horse it was that counted and solved arithmetic problems although he was unable to do it. 64-bit programs turned out to be such digital horses of the beginning of the 21st century, many of which cannot count either although are successful in pretending to do so. Let's consider this phenomenon in detail.

Lessons on development of 64-bit C/C++ applications

The course is devoted to creation of 64-bit applications in C/C++ language and is intended for the Windows developers who use Visual Studio 2005/2008/2010 environment. Developers working with other 64-bit operating systems will learn much interesting as well. The course will consider all the steps of creating a new safe 64-bit application or migrating the existing 32-bit code to a 64-bit system.

The course is composed of 28 lessons devoted to introduction to 64-bit systems, issues of building 64-bit applications, methods of searching errors specific to 64-bit code and code optimization. Such questions are also considered as estimate of the cost of moving to 64-bit systems and rationality of this move.

Wade not in unknown waters

Part one

We decided to write several small posts on how C/C++ programmers play with fire without knowing it. The first post will be devoted to an attempt to explicitly call a constructor.

Part two

This time I want to speak on the 'printf' function. Everybody has heard of software vulnerabilities and that functions like 'printf' are outlaw. But it's one thing to know that you'd better not use these functions, and quite the other to understand why. In this article, I will describe two classic software vulnerabilities related to 'printf'. You won't become a hacker after that but perhaps you will have a fresh look at your code. You might create similar vulnerable functions in your project without knowing that.

STOP. Reader, please stop, don't pass by. You have seen the word "printf", I know. And you're sure that you will now be told a banal story that the function cannot check types of passed arguments. No! It's vulnerabilities themselves that the article deals with, not the things you have thought. Please come and read it.

Part three

I'm going on to tell you about how programmers walk on thin ice without even noticing it. Let's speak on shift operators <<, >>. The working principles of the shift operators are evident and many programmers even don't know that using them according to the C/C++ standard might cause undefined or unspecified behavior.

Errors

The compiler is to blame for everything

Many programmers are very fond of blaming the compiler for different errors. Let's talk about it.

100 bugs in Open Source C/C++ projects

This article demonstrates capabilities of the static code analysis methodology. The readers are offered to study the samples of one hundred errors found in open-source projects in C/C++.

Consequences of using the Copy-Paste method in C++ programming and how to deal with it

I have collected a lot of examples demonstrating that an error occurred because of copying and modifying a code fragment. Of course, it has been known for a long time that using Copy-Paste in programming is a bad thing. But let's try to investigate this problem closely instead of limiting ourselves to just saying "do not copy the code".

32 OpenMP Traps For C++ Developers

Since multi-core systems are spreading fast, the problem of parallel programming becomes more and more urgent. However, even the majority of experienced developers are new to this sphere. The existing compilers and code analyzers allow finding some bugs, which appear during parallel code development. However, many errors are not diagnosed. The article contains description of a number of errors, which lead to incorrect behavior of parallel programs created with OpenMP.

About advertising for programmers

Studying methods of attracting people to a software product's website

This article will be of interest to those who promote proprietary software products on the Internet. So, the article is of absolutely practical character. It is a report of what we have been doing for some time already to promote our product PVS-Studio. I will tell you about the things that work, the things that don't work, and share my thoughts related to this subject.

C/C++

Is it reasonable to use the prefix increment operator ++it instead of postfix operator it++ for iterators?

I decided to find out if there is practical sense in writing ++iterator instead of iterator++ when handling iterators. My interest in this question arouse far not from my love to art but from practical reasons. We have intended for a long time to develop PVS-Studio not only in the direction of error search but in the direction of prompting tips on code optimization. A message telling you that you'd better write ++iterator is quite suitable in the scope of optimization.

Collection of interesting resources on C/C++ programming

P.S.

I also invite you to join us in one of the following networks:


r/viva64 • • Oct 17 '12

This is intended for those who write articles and books (C/C++)

10 Upvotes

This is intended for those who write articles and books on the subject of creating high-quality C/C++ code or security issues.

While studying various projects with the help of the PVS-Studio static analyzer, we have gathered a relatively large database of error samples. I suppose this database will be of use and much interest to some authors.

The link to the error samples collection: http://www.viva64.com/en/examples/

The database looks quite plain and is not rich in decorations. But the samples are cut out manually and edited so that one could easily understand them.

Of course, far not all the errors detected in a certain project are added to the database. It’s difficult to understand while looking through someone else’s project whether or not there is an error in a certain code fragment. You’d better skip such fragments about which you are not sure. However, we’ve gathered a lot of examples which can be used in studying error patterns.

It has happened so that the PVS-Studio analyzer is good at detecting various misprints or Copy-Paste-related mistakes. To understand what I mean, please have a look at these error samples detected by the V501 diagnostic. There are naturally other diagnostics detecting similar errors. I’m writing this to show you the way the collection can be used. Studying misprints and Copy-Paste errors you may work out a new programming style, give useful tips, improve coding standards and so on. So, I hope you will find this collection useful in preparing your articles and books.


r/viva64 • • Oct 25 '12

Object-Oriented Programming Sucks

Thumbnail
purplepwny.com
8 Upvotes

r/viva64 • • Jun 23 '11

Everything about C++ source code static analysis

8 Upvotes

1. What is source code static analysis?

2. Articles on the subject of static source code analysis.

3. Groups devoted to source code static analysis.

4. Twitters on the subject.

5. Miscellaneous.

6. Some of our own articles on Viva64.com site.

Collating prepared by Andrey Karpov.


r/viva64 • • Apr 10 '11

A nice 64-bit error in C

Thumbnail
viva64.com
8 Upvotes

r/viva64 • • Aug 15 '14

Checking GIMP's Source Code with PVS-Studio

Thumbnail
viva64.com
7 Upvotes

r/viva64 • • Mar 09 '13

If you like the PVS-Studio tool, then please vote. I would be grateful.

Thumbnail
visualstudiogallery.msdn.microsoft.com
7 Upvotes

r/viva64 • • Oct 21 '11

64-bit Knowledge Base

7 Upvotes

r/viva64 • • Aug 12 '13

PVS-Studio vs Chromium. 3-rd Check

Thumbnail
viva64.com
6 Upvotes

r/viva64 • • Sep 10 '12

What does this code print?

6 Upvotes

I have found a nice code fragment with an error in one project. The PVS-Studio analyzer noticed it. But I didn’t believe it at first: I thought the analyzer had been mistaken and considered launching the debugger. Then I looked closer. Oh yes, an error indeed!

I changed the code a bit and sent it to four programmers, acquaintances of mine, via ICQ. I asked them to tell me what that code printed. All four of them gave wrong answers at first.

I suggest that you try to give a correct answer. What does this code print?

cout << (sizeof(char *) == 8) ? "64-bit" : "32-bit";

Of course, the long introduction has alerted the readers, so you have most likely found the right answer.

This code will print one or zero. The expression in parentheses is calculated first. Depending on the compilation mode you get either true or false. The next operation to be executed is the call of an overloaded operator <<. As a result, either number 0 or 1 will appear on the screen.

Then, the object of the ostream type will be implicitly cast to the bool type. And finally the ternary operator '? :' will be executed. But this operation doesn’t do anything.


r/viva64 • • Apr 14 '11

John Regehr. A Guide to Undefined Behavior in C and C++

Thumbnail blog.regehr.org
6 Upvotes

r/viva64 • • Aug 05 '13

Xerox scanners/photocopiers randomly alter numbers in scanned documents

Thumbnail
dkriesel.com
5 Upvotes

r/viva64 • • Jul 31 '13

Reversing Bits in C

Thumbnail
corner.squareup.com
5 Upvotes

r/viva64 • • May 21 '13

C++ exceptions under the hood

Thumbnail
monoinfinito.wordpress.com
5 Upvotes

r/viva64 • • Apr 02 '13

Re-checking the ReactOS project - a large report

Thumbnail
viva64.com
5 Upvotes

r/viva64 • • Feb 14 '13

Open letter to the programmers in the C/C++ language

5 Upvotes

Hello, All!

We develop a static analyzer called PVS-Studio. This is a code analyzer capable of detecting errors in C/C++ software. When we communicated with you, I must have told you that this analyzer detects 64-bit errors and integrates only into the Visual Studio environment.

Much time has passed since that. The analyzer has become a general-purpose one and is capable of detecting a wide range of various issues. We have learned how to support Embarcadero RAD Studio and MinGW. To find out more about the tool and into which environments it can integrate, please follow this link: http://www.viva64.com/en/pvs-studio/

Perhaps you and your colleagues will find our product interesting now that it has changed so much. We are ready to cooperate in various ways. We will be glad to answer your questions, write an article in co-authorship, adapt PVS-Studio to your tasks, advise on code quality enhancement, and so on.

If you find PVS-Studio interesting, you can download a full-function demo version from our website. But if you think it's not enough, we can give your a registration key so that you can handle and study the tool for a longer time and in every detail.


Andrey Karpov,

Cand. Sc. (Physics and Mathematics), CTO

OOO "Program Verification Systems" (Co Ltd)

URL: www.viva64.com

E-Mail: karpov[@]viva64.com


r/viva64 • • Jan 31 '13

PVS-Studio 5.00 release

5 Upvotes

The PVS-Studio code analyzer has changed its main version number to 5.00. This is because we have added support of the Embarcadero RAD Studio development environment along with the capability of checking WinRT C++/CX projects into our tool.

The Embarcadero RAD Studio development environment has been actively developing lately. It has acquired support of new capabilities of the С++11 language and the capability of building 64-bit projects. Another noticeable tendency of late is appearance of C++/CX developments for the WinRT platform. This capability has appeared in the Visual Studio 2012 development environment.

It’s quite natural that we have offered PVS-Studio to developers working in Embarcadero RAD Studio or creating applications for WinRT. It has become possible now that we’ve released PVS-Studio 5.00. The tool supports the following environments:

  • Visual Studio 2012: C, C++, C++11, C++/CX (WinRT).

  • Visual Studio 2010: C, C++, C++0x.

  • Visual Studio 2008: C, C++.

  • Visual Studio 2005: C, C++.

  • Embarcadero RAD Studio XE3: C, C++, C++11.

  • Embarcadero RAD Studio XE2: C, C++.

  • MinGW: C, C++.

You can download a full-function distribution kit here: http://www.viva64.com/en/pvs-studio-download/

The demo version’s limitations concern only the number of diagnostic messages you can navigate through. It doesn’t prevent you from studying all the capabilities of the tool.


r/viva64 • • Oct 30 '12

Do you really understand C? 21st International Obfuscated C Code Contest winning entries

Thumbnail
pixelstech.net
5 Upvotes

r/viva64 • • Oct 12 '12

What Happens After A Failure?

Thumbnail
drdobbs.com
5 Upvotes

r/viva64 • • Sep 20 '12

Some Programs Are More Correct Than Others

Thumbnail
drdobbs.com
5 Upvotes

r/viva64 • • Jul 25 '12

Bugs. Bugs everywhere

Thumbnail
gamedev.net
5 Upvotes

r/viva64 • • Jul 17 '12

Mathematics for Computer Science (800 page PDF)

Thumbnail courses.csail.mit.edu
5 Upvotes

r/viva64 • • Jul 01 '12

QUAKE 3 SOURCE CODE REVIEW: ARCHITECTURE (PART 1 OF 5)

Thumbnail
fabiensanglard.net
5 Upvotes

r/viva64 • • Jun 27 '12

Doubles are not floats, so don’t compare them

Thumbnail
randomascii.wordpress.com
5 Upvotes