The article is a report about testing of portability of Loki library with 64-bit systems with the help of Viva64 code analyzer performed by OOO "Program Verification Systems" Company. It contains recommendations for users of the library. The article will be also useful for the users of other libraries built on templates for it describes the peculiarities of analysis of such libraries.
A Collection of Examples of 64-bit Errors in Real ProgramsAndrey Karpov
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.
The document provides an overview of getting started with C#, including:
- An introduction to C# and its evolution from versions 1.0 to 9.0.
- Key topics covered include data types, variables, value types vs reference types, and keywords.
- Coding standards, sample programs, and operators are also discussed to help newcomers get up and running with C#.
A Collection of Examples of 64-bit Errors in Real ProgramsPVS-Studio
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.
Porting is a Delicate Matter: Checking Far Manager under LinuxPVS-Studio
Far Manager, which takes over from Norton Commander, created back in the times of DOS, is one of the most popular file managers on Microsoft Windows. Far Manager facilitates the file system management (file creation, editing, viewing, copying, moving, search, and deletion) and provides means to extend the standard feature set (handling of the network, archives, backup copies, and so on). Far Manager was recently ported to Linux, and there is currently an alpha version available. The PVS-Studio team couldn't ignore that event and miss the opportunity to test the quality of the ported code.
A collection of examples of 64 bit errors in real programsMichael Scovetta
This document provides 30 examples of common 64-bit errors found in real C/C++ programs. The examples cover a wide range of issues like buffer overflows, unnecessary type conversions, incorrect preprocessor directives, pointer/integer confusion, use of deprecated functions, truncation of values during type conversions, undefined functions, legacy code practices, and more. The goal is to help developers identify and avoid such 64-bit porting issues when moving applications to 64-bit systems.
The Onward Journey: Porting Twisted to Python 3Craig Rodrigues
This document discusses porting the Twisted Python library to Python 3. It describes Twisted as a networking library that uses asynchronous programming. The author ported over 325 pull requests to help move Twisted to Python 3. Some challenges included changes to Python 3 like print becoming a function and str handling, as well as porting old C extensions. Running extensive unit tests was important. While difficult, porting benefits code quality and keeps Twisted compatible with Python's direction.
Manage software dependencies with ioc and aopStefano Leli
The document discusses managing software dependencies through inversion of control (IoC) and aspect-oriented programming (AOP). It describes how dependencies can make software rigid, fragile, and difficult to maintain. It then shows how to decouple dependencies using IoC patterns like dependency injection and AOP to address cross-cutting concerns.
The Chromium browser is developing very fast. When we checked the solution for the first time in 2011, it included 473 projects. Now it includes 1169 projects. We were curious to know if Google developers had managed to keep the highest quality of their code with Chromium developing at such a fast rate. Well, they had.
A Collection of Examples of 64-bit Errors in Real ProgramsAndrey Karpov
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.
The document provides an overview of getting started with C#, including:
- An introduction to C# and its evolution from versions 1.0 to 9.0.
- Key topics covered include data types, variables, value types vs reference types, and keywords.
- Coding standards, sample programs, and operators are also discussed to help newcomers get up and running with C#.
A Collection of Examples of 64-bit Errors in Real ProgramsPVS-Studio
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.
Porting is a Delicate Matter: Checking Far Manager under LinuxPVS-Studio
Far Manager, which takes over from Norton Commander, created back in the times of DOS, is one of the most popular file managers on Microsoft Windows. Far Manager facilitates the file system management (file creation, editing, viewing, copying, moving, search, and deletion) and provides means to extend the standard feature set (handling of the network, archives, backup copies, and so on). Far Manager was recently ported to Linux, and there is currently an alpha version available. The PVS-Studio team couldn't ignore that event and miss the opportunity to test the quality of the ported code.
A collection of examples of 64 bit errors in real programsMichael Scovetta
This document provides 30 examples of common 64-bit errors found in real C/C++ programs. The examples cover a wide range of issues like buffer overflows, unnecessary type conversions, incorrect preprocessor directives, pointer/integer confusion, use of deprecated functions, truncation of values during type conversions, undefined functions, legacy code practices, and more. The goal is to help developers identify and avoid such 64-bit porting issues when moving applications to 64-bit systems.
The Onward Journey: Porting Twisted to Python 3Craig Rodrigues
This document discusses porting the Twisted Python library to Python 3. It describes Twisted as a networking library that uses asynchronous programming. The author ported over 325 pull requests to help move Twisted to Python 3. Some challenges included changes to Python 3 like print becoming a function and str handling, as well as porting old C extensions. Running extensive unit tests was important. While difficult, porting benefits code quality and keeps Twisted compatible with Python's direction.
Manage software dependencies with ioc and aopStefano Leli
The document discusses managing software dependencies through inversion of control (IoC) and aspect-oriented programming (AOP). It describes how dependencies can make software rigid, fragile, and difficult to maintain. It then shows how to decouple dependencies using IoC patterns like dependency injection and AOP to address cross-cutting concerns.
The Chromium browser is developing very fast. When we checked the solution for the first time in 2011, it included 473 projects. Now it includes 1169 projects. We were curious to know if Google developers had managed to keep the highest quality of their code with Chromium developing at such a fast rate. Well, they had.
The document discusses Delphi interfaces and their implementation. It explains that interfaces allow for loosely coupled and more flexible code by making implementations independent. Interfaces were introduced in Delphi 3 and allow classes to implement multiple interfaces. The key methods for interfaces are QueryInterface, _AddRef, and _Release which control interface reference counting. QueryInterface returns a pointer to the interface implementation, while _AddRef and _Release manage the reference counter.
Static code analysis for verification of the 64-bit applicationsPVS-Studio
The coming of 64-bit processors to the PC market causes a problem which the developers have to solve: the old 32-bit applications should be ported to the new platform. After such code migration an application may behave incorrectly. The article is elucidating question of development and appliance of static code analyzer for checking out of the correctness of such application. Some problems emerging in applications after recompiling in 64-bit systems are considered in this article as well as the rules according to which the code check up is performed.
This PPT File helps IT freshers with the Basic Interview Questions, which will boost there confidence before going to the Interview. For more details and Interview Questions please log in www.rekruitin.com and click on Job Seeker tools. Also register on the and get employed.
By ReKruiTIn.com
This document provides an introduction and overview of the Python programming language. It discusses what Python is, why to learn a scripting language and why Python specifically. It covers how to install Python and how to edit Python code using IDLE. The rest of the document demonstrates various Python concepts like variables, data types, operators, flow control statements, functions and more through sample code examples. Each code example is accompanied by instructions to run the sample script in IDLE.
Use of Cell Block As An Indent Space In PythonWaqas Tariq
The document proposes using cell blocks in spreadsheets to visualize Python source code indentation. It introduces the Stereopsis algorithm to analyze source code indentation using two views - left eye and right eye. This helps identify inconsistencies in indentation. Cell blocks are used to represent indentation levels and colored cell blocks provide an additional visual cue. The approach aims to help programmers easily identify indentation errors without compiling code. Sample Python code is analyzed using the proposed approach to demonstrate how indentation errors can be detected.
The document introduces LLVM and its intermediate representation (IR) for program analysis. It describes how LLVM IR uses static single assignment form and three-address code. It shows examples of common LLVM IR instructions like arithmetic operations, branches, function calls and definitions. It explains how to use the 'opt' command to run analysis passes and print outputs like call graphs. It provides guidance on writing custom analysis passes and installing LLVM to build and run them.
DEF CON 23 - Saif el-sherei and etienne stalmans - fuzzingFelipe Prado
The document describes the Wadi fuzzer. Wadi uses grammars derived from interface definition language (IDL) specifications to generate valid test cases for fuzzing browsers. It creates elements, sets attributes and styles, and calls methods to expose bugs. Wadi has found several high severity bugs in browsers like Chrome and Firefox. It works by generating JavaScript statements that manipulate the DOM and APIs based on the IDL grammars, then outputs an HTML page containing the fuzzing script.
The document provides an overview of the Python programming language. It discusses that Python is an easy to learn, high-level, open-source programming language. It describes Python's design philosophy of code readability and how it allows programmers to express concepts in fewer lines of code compared to languages like C++ and Java. The document also discusses Python's powerful libraries, wide use across industries, and how to get started with Python programming using the IDLE integrated development environment.
The document provides an introduction to VB.NET, including definitions of the .NET framework and common language runtime (CLR). It discusses how the CLR converts code into an intermediate language and handles memory management, threading, exceptions and security. It also summarizes some common namespaces used in .NET applications and provides simple examples of console and windows applications built in VB.NET.
Static code analysis and the new language standard C++0xAndrey Karpov
The article discusses the new capabilities of C++ language described in the standard C++0x and supported in Visual Studio 2010. By the example of PVS-Studio we will see how the changes in the language influence static code analysis tools.
Static code analysis and the new language standard C++0xPVS-Studio
The article discusses the new capabilities of C++ language described in the standard C++0x and supported in Visual Studio 2010. By the example of PVS-Studio we will see how the changes in the language influence static code analysis tools.
COM (Component Object Model) is a binary standard for software componentry introduced by Microsoft in the early 1990s. It allows for the creation of binary reusable software components that can be integrated into various programming languages and applications. COM defines concepts like interfaces, object lifetime management, and a mechanism for late-binding between components. It provides a way to build and distribute reusable software components independently of any programming language.
The document discusses conditional statements and loops in Visual Basic .NET. It explains the syntax of if/else conditional statements and select case statements. It also describes the syntax and provides examples of different types of loops - for loops, while loops, and do loops. Key loops covered include for loops using an index variable, while loops that execute until a condition is met, and do loops that can use while or until conditions.
DEF CON 23 - Topher Timzen and Ryan Allen - Hijacking Arbitrary NET App Contr...Felipe Prado
This paper describes how the Gray Storm tool takes advantage of reflection capabilities and just-in-time compilation in the .NET framework to hijack the control flow of arbitrary .NET applications. It does this by injecting itself into the target process, using reflection to find method addresses and metadata, and then overwriting memory or method tables to redirect execution to malicious payloads. The tool can change method calls, replace method tables, compile and execute code dynamically, overwrite methods with assembly payloads, and manipulate objects - demonstrating that the .NET framework leaves processes insecure after JIT compilation by not marking memory as non-executable.
This document provides an introduction to PC-lint, a static code analysis tool for C and C++. It discusses some common mistakes made in C and C++ programs that PC-lint can detect. It then gives an overview of PC-lint, describing what it is, the types of checks it performs, and some of its key features like weak definials checking, const-correctness checking, value tracking, semantics analysis, multi-thread support, and support for MISRA coding standards. The document concludes by demonstrating how to use PC-lint via the command line and customize its message output.
The document discusses various aspects of .NET Framework including its components, new features in .NET 4.0, intermediate language, garbage collection, and more. It provides definitions and explanations for terms like Common Language Runtime, assemblies, generics, and tuples. Key points covered are the main components of .NET Framework, new features in .NET 4.0 like parallel programming and security improvements, and differences between managed and unmanaged code.
This material is developed in such beautiful manner to the beginners of C language can understand it accurately.
Every concept In material is explained in well disciplined.
Even it will be helpful to the professors for presenting lecture in class room
C Programming and CPP Programming Interview Questions and Answers.
Here is link to my complete course ISTQB - Foundation Level Certification (CTFL) Training Udemy with 40% discount.
https://www.udemy.com/istqb-foundation-level-certification-ctfl-training/?couponCode=SAGARREF
Coupon code: SAGARREF
The document discusses optimization strategies for 64-bit programs. It explains that porting 32-bit applications to 64-bit can provide a 2-15% performance boost by eliminating the 32-bit emulation layer. Using 64-bit data types like ptrdiff_t and size_t as loop counters and indexes can optimize code speed by up to 30%. Proper struct layout and avoiding excessive memory usage, such as large stack allocations or pointer arrays for text processing, can decrease memory consumption which indirectly improves performance.
The forgotten problems of 64-bit programs developmentPVS-Studio
Though the history of 64-bit systems development makes more than a decade, the appearance of 64-bit version of OS Windows raised new problems in the sphere of development and testing applications. In the article there are considered some mistakes connected with 64-bit C/C++ code development to OS Windows. The reasons are explained according to which these mistakes didn't find their reflection in the articles devoted to the migration tasks and are unsatisfactorily detected by the majority of static analyzers.
Comparing capabilities of PVS-Studio and Visual Studio 2010 in detecting defe...PVS-Studio
In the article, we will compare three mechanisms of code analysis from the viewpoint of detecting 64-bit errors: the Visual C++ 2010 compiler, the Code Analysis for C/C++ component included into Visual Studio 2010 and Viva64 analyzer included into PVS-Studio 3.60. I will show both the capabilities of detecting defects in 64-bit projects and preliminary diagnosis of 64-bit errors in the 32-bit code of projects.
The document discusses Delphi interfaces and their implementation. It explains that interfaces allow for loosely coupled and more flexible code by making implementations independent. Interfaces were introduced in Delphi 3 and allow classes to implement multiple interfaces. The key methods for interfaces are QueryInterface, _AddRef, and _Release which control interface reference counting. QueryInterface returns a pointer to the interface implementation, while _AddRef and _Release manage the reference counter.
Static code analysis for verification of the 64-bit applicationsPVS-Studio
The coming of 64-bit processors to the PC market causes a problem which the developers have to solve: the old 32-bit applications should be ported to the new platform. After such code migration an application may behave incorrectly. The article is elucidating question of development and appliance of static code analyzer for checking out of the correctness of such application. Some problems emerging in applications after recompiling in 64-bit systems are considered in this article as well as the rules according to which the code check up is performed.
This PPT File helps IT freshers with the Basic Interview Questions, which will boost there confidence before going to the Interview. For more details and Interview Questions please log in www.rekruitin.com and click on Job Seeker tools. Also register on the and get employed.
By ReKruiTIn.com
This document provides an introduction and overview of the Python programming language. It discusses what Python is, why to learn a scripting language and why Python specifically. It covers how to install Python and how to edit Python code using IDLE. The rest of the document demonstrates various Python concepts like variables, data types, operators, flow control statements, functions and more through sample code examples. Each code example is accompanied by instructions to run the sample script in IDLE.
Use of Cell Block As An Indent Space In PythonWaqas Tariq
The document proposes using cell blocks in spreadsheets to visualize Python source code indentation. It introduces the Stereopsis algorithm to analyze source code indentation using two views - left eye and right eye. This helps identify inconsistencies in indentation. Cell blocks are used to represent indentation levels and colored cell blocks provide an additional visual cue. The approach aims to help programmers easily identify indentation errors without compiling code. Sample Python code is analyzed using the proposed approach to demonstrate how indentation errors can be detected.
The document introduces LLVM and its intermediate representation (IR) for program analysis. It describes how LLVM IR uses static single assignment form and three-address code. It shows examples of common LLVM IR instructions like arithmetic operations, branches, function calls and definitions. It explains how to use the 'opt' command to run analysis passes and print outputs like call graphs. It provides guidance on writing custom analysis passes and installing LLVM to build and run them.
DEF CON 23 - Saif el-sherei and etienne stalmans - fuzzingFelipe Prado
The document describes the Wadi fuzzer. Wadi uses grammars derived from interface definition language (IDL) specifications to generate valid test cases for fuzzing browsers. It creates elements, sets attributes and styles, and calls methods to expose bugs. Wadi has found several high severity bugs in browsers like Chrome and Firefox. It works by generating JavaScript statements that manipulate the DOM and APIs based on the IDL grammars, then outputs an HTML page containing the fuzzing script.
The document provides an overview of the Python programming language. It discusses that Python is an easy to learn, high-level, open-source programming language. It describes Python's design philosophy of code readability and how it allows programmers to express concepts in fewer lines of code compared to languages like C++ and Java. The document also discusses Python's powerful libraries, wide use across industries, and how to get started with Python programming using the IDLE integrated development environment.
The document provides an introduction to VB.NET, including definitions of the .NET framework and common language runtime (CLR). It discusses how the CLR converts code into an intermediate language and handles memory management, threading, exceptions and security. It also summarizes some common namespaces used in .NET applications and provides simple examples of console and windows applications built in VB.NET.
Static code analysis and the new language standard C++0xAndrey Karpov
The article discusses the new capabilities of C++ language described in the standard C++0x and supported in Visual Studio 2010. By the example of PVS-Studio we will see how the changes in the language influence static code analysis tools.
Static code analysis and the new language standard C++0xPVS-Studio
The article discusses the new capabilities of C++ language described in the standard C++0x and supported in Visual Studio 2010. By the example of PVS-Studio we will see how the changes in the language influence static code analysis tools.
COM (Component Object Model) is a binary standard for software componentry introduced by Microsoft in the early 1990s. It allows for the creation of binary reusable software components that can be integrated into various programming languages and applications. COM defines concepts like interfaces, object lifetime management, and a mechanism for late-binding between components. It provides a way to build and distribute reusable software components independently of any programming language.
The document discusses conditional statements and loops in Visual Basic .NET. It explains the syntax of if/else conditional statements and select case statements. It also describes the syntax and provides examples of different types of loops - for loops, while loops, and do loops. Key loops covered include for loops using an index variable, while loops that execute until a condition is met, and do loops that can use while or until conditions.
DEF CON 23 - Topher Timzen and Ryan Allen - Hijacking Arbitrary NET App Contr...Felipe Prado
This paper describes how the Gray Storm tool takes advantage of reflection capabilities and just-in-time compilation in the .NET framework to hijack the control flow of arbitrary .NET applications. It does this by injecting itself into the target process, using reflection to find method addresses and metadata, and then overwriting memory or method tables to redirect execution to malicious payloads. The tool can change method calls, replace method tables, compile and execute code dynamically, overwrite methods with assembly payloads, and manipulate objects - demonstrating that the .NET framework leaves processes insecure after JIT compilation by not marking memory as non-executable.
This document provides an introduction to PC-lint, a static code analysis tool for C and C++. It discusses some common mistakes made in C and C++ programs that PC-lint can detect. It then gives an overview of PC-lint, describing what it is, the types of checks it performs, and some of its key features like weak definials checking, const-correctness checking, value tracking, semantics analysis, multi-thread support, and support for MISRA coding standards. The document concludes by demonstrating how to use PC-lint via the command line and customize its message output.
The document discusses various aspects of .NET Framework including its components, new features in .NET 4.0, intermediate language, garbage collection, and more. It provides definitions and explanations for terms like Common Language Runtime, assemblies, generics, and tuples. Key points covered are the main components of .NET Framework, new features in .NET 4.0 like parallel programming and security improvements, and differences between managed and unmanaged code.
This material is developed in such beautiful manner to the beginners of C language can understand it accurately.
Every concept In material is explained in well disciplined.
Even it will be helpful to the professors for presenting lecture in class room
C Programming and CPP Programming Interview Questions and Answers.
Here is link to my complete course ISTQB - Foundation Level Certification (CTFL) Training Udemy with 40% discount.
https://www.udemy.com/istqb-foundation-level-certification-ctfl-training/?couponCode=SAGARREF
Coupon code: SAGARREF
The document discusses optimization strategies for 64-bit programs. It explains that porting 32-bit applications to 64-bit can provide a 2-15% performance boost by eliminating the 32-bit emulation layer. Using 64-bit data types like ptrdiff_t and size_t as loop counters and indexes can optimize code speed by up to 30%. Proper struct layout and avoiding excessive memory usage, such as large stack allocations or pointer arrays for text processing, can decrease memory consumption which indirectly improves performance.
The forgotten problems of 64-bit programs developmentPVS-Studio
Though the history of 64-bit systems development makes more than a decade, the appearance of 64-bit version of OS Windows raised new problems in the sphere of development and testing applications. In the article there are considered some mistakes connected with 64-bit C/C++ code development to OS Windows. The reasons are explained according to which these mistakes didn't find their reflection in the articles devoted to the migration tasks and are unsatisfactorily detected by the majority of static analyzers.
Comparing capabilities of PVS-Studio and Visual Studio 2010 in detecting defe...PVS-Studio
In the article, we will compare three mechanisms of code analysis from the viewpoint of detecting 64-bit errors: the Visual C++ 2010 compiler, the Code Analysis for C/C++ component included into Visual Studio 2010 and Viva64 analyzer included into PVS-Studio 3.60. I will show both the capabilities of detecting defects in 64-bit projects and preliminary diagnosis of 64-bit errors in the 32-bit code of projects.
Introduction into 64 bits for the beginners or where's again the 64-bit world?PVS-Studio
1) The transition to 64-bit computing began in 2003-2004 but has not been fully realized yet due to various challenges.
2) One challenge was the lack of 64-bit operating systems and drivers, as well as 64-bit versions of most popular software programs.
3) Porting existing 32-bit software to 64-bit versions proved difficult, as unexpected errors could occur, and testing tools were not adequate for discovering 64-bit specific issues until recently.
Questions concerned with the release of drivers for 64-bit versions of Windows are considered in this article. Some typical problems and the ways of their solutions are listed in the article as well as tools which simplify the process of drivers developing.
The article describes the testing technologies used when developing PVS-Studio static code analyzer. The developers of the tool for programmers talk about the principles of testing their own program product which can be interesting for the developers of similar packages for processing text data or source code.
Brief description of the VivaCore code analysis libraryPVS-Studio
While investigating the sphere of static analysis and working on the creation of the Viva64 tool our team came to a conclusion that the most part of the developed structures and algorithms can be united into a library and used by third-party developers for creating new software products. This library has been named VivaCore.
The essence of the VivaCore code analysis libraryPVS-Studio
The article tells developers about VivaCore library, preconditions of its creation, its possibilities, structure and scope of use. This article was written simultaneously with the development of VivaCore library and that's why some of the details of the final realization may differ from the features described here. But this won't prevent the developers from getting acquainted with the general work principles of the library, mechanisms of analysis and processing of C and C++ source code.
20 issues of porting C++ code on the 64-bit platformPVS-Studio
Program errors occurring while porting C++ code from 32-bit platforms on 64-bit ones are observed. Examples of the incorrect code and the ways to correct it are given. Methods and means of the code analysis which allow to diagnose the errors discussed, are listed.
Even if you correct all compilation errors and warnings, it does not mean that a 64-bit application will work well. So it is the description and diagnosis of 64-bit errors that we will deal with in the most lessons of our course. And one more thing - do not rely on the switch /Wp64 which is described by many people (often unreasonably) in forum discussions as a wonderful tool able to find 64-bit errors.
Viva64: working up of 64-bit applicationsPVS-Studio
Viva64 is a static code analysis tool that helps detect errors and issues when porting C/C++ applications to 64-bit platforms. It integrates directly with Visual Studio 2005, allowing developers to check for 64-bit portability issues and incorrect code constructions. Viva64 can analyze entire projects and provides detailed diagnostics and references to help developers understand and fix issues. While it cannot replace full testing, using Viva64 during development can significantly improve code quality and reduce bugs when porting to 64-bit.
This document summarizes a knowledge sharing session on Javascript sourcemaps and Angular compilation. It discusses how sourcemaps allow minified code to be mapped back to original source code for debugging purposes. It also explains the different stages of Angular compilation including initialization, analysis, resolution, type checking and emitting. The key differences between just-in-time (JIT) compilation and ahead-of-time (AOT) compilation are outlined, noting that AOT produces smaller bundles but requires compilation during the build. The advantages of sourcemaps and AOT for production use are highlighted.
Stefan Richter - Writing simple, readable and robust code: Examples in Java, ...AboutYouGmbH
Stefan Richter gave a presentation on writing simple, readable, and robust code using examples in Java, Clojure, and Go. He discussed his programming experience and showed how Martin Fowler used Java to parse a fixed-length file format into objects. Richter then demonstrated how the same task could be accomplished more concisely in Common Lisp and Clojure using macros to define domain-specific languages. He argued that macros are a powerful feature of Lisp-like languages.
This document provides an overview of OpenFrameworks for Flash developers. It includes:
1. An introduction to OpenFrameworks and how it can be used to create C++ applications with less hassle than traditional methods.
2. A breakdown of the basic structure of an OpenFrameworks application including the main classes and functions.
3. Step-by-step explanations of three example OpenFrameworks projects that create circles, an animation, and particles.
4. Additional resources for learning more about OpenFrameworks, creative coding, and getting involved in the OpenFrameworks community.
The document discusses writing C code for the 8051 microcontroller using the Keil compiler. It describes the Keil compiler's limitations in the evaluation version, modifications made to the C language to support microcontrollers, and provides examples of writing C code that interfaces with hardware registers and uses interrupts. The purpose is to explain how to develop software for the 8051 microcontroller using the Keil compiler and its C extensions.
Monitoring a program that monitors computer networksPVS-Studio
The document discusses several types of errors found using static analysis on the NetXMS open source project codebase. It describes 4 examples of 64-bit errors where pointers are incorrectly cast to 32-bit types. It also mentions errors handling unsigned types like sockets, half-cleared buffers due to misunderstanding string sizes, copy-paste errors, uninitialized variables, null pointer dereferences, and incorrect variable type usage with variadic functions. The author encourages the NetXMS developers to use the static analysis tool to find and address these kinds of issues in their code.
Linux executables are in ELF format. The document discusses Linux executable formats, compiling C programs in Linux using GCC, and executing programs. It also covers libraries in Linux including static and shared libraries, error handling using errno and assertions, signals and signal handling, process monitoring and /proc filesystem, and managing command line arguments using getopt_long.
In this article, we will speak about the static analysis of the doxygen documentation generator tool. This popular and widely used project, which, as its authors claim, not without reason, has become "the de facto standard tool for generating documentation from annotated C++ sources", has never been scanned by PVS-Studio before. Doxygen scans the program source code and generates the documentation relying on it. Now it's time for us to peep into its source files and see if PVS-Studio can find any interesting bugs there.
PVS-Studio, a solution for developers of modern resource-intensive applicationsPVS-Studio
The PVS-Studio tool
the Viva64 rule set for 64-bit software analysis;
the VivaMP rule set for parallel software analysis;
the general-purpose analysis rule set.
Licensing and pricing policy forPVS-Studio
About the OOO “Program Verification Systems” company
I just cannot pass by the source code of ICQ messenger. It is a kind of a cult project, and when I saw the source code on GitHub, it was just a matter of time, when we will check it with PVS-Studio. Of course, we have a lot of other interesting projects that are waiting to be checked. For example, we have recently checked GCC, GDB, Mono. Finally, it's the turn of ICQ.
Après avoir fait ce talk à la conférence NSSpain, Simone Civetta va nous expliquer sur quelles métriques il est possible de se baser pour évaluer la qualité d’un code source. Cette question étant toujours sujette à débat, préparez vos arguments !
This document provides an overview of the key updates and new features between Android KK and Android L, including new APIs, security enhancements like verified boot, improved performance with ART and the new garbage collector, and support for interacting with other devices like Android Auto and Android Wear. It also discusses maintainability improvements like splitting monolithic APKs and using dynamic resource overlays. Finally, it outlines some features that may be included in Android M like modularity, enhanced security through dynamic permission checking, and multi-SIM card support.
Monitoring a program that monitors computer networksAndrey Karpov
There exists the NetXMS project, which is a software product designed to monitor computer systems and networks. It can be used to monitor the whole IT-infrastructure, from SNMP-compatible devices to server software. And I am naturally going to monitor the code of this project with the PVS-Studio analyzer.
A Check of the Open-Source Project WinSCP Developed in Embarcadero C++ BuilderAndrey Karpov
We regularly check open-source C/C++ projects, but what we check are mostly projects developed in the Visual Studio IDE. For some reason, we haven't paid much attention to the Embarcadero C++ Builder IDE. In order to improve this situation, we are going to discuss the WinSCP project I have checked recently.
P.S. C++ Builder support in PVS-Studio had been dropped after version 5.20. If you have any questions, feel free to contact our support.
Build Great Networked APIs with Swift, OpenAPI, and gRPCTim Burks
This document discusses building APIs with Swift, OpenAPI, and gRPC. It introduces protocol buffers for defining data structures, and gRPC for building APIs. It recommends using the gnostic tool to convert OpenAPI descriptions to protocol buffers for use with gRPC plugins. This allows building high-quality code generators in different languages by separating the generator from the API description parsing. The document provides examples of building gRPC APIs and clients in Swift.
This document provides an overview of embedded C programming concepts including:
- The C preprocessor and directives like #define, #include, #if.
- Bitwise operations like bit masking, setting, clearing, and toggling bits.
- Type qualifiers like const and volatile and their usage.
- Compiler optimization levels and tradeoffs between execution time, code size, and memory usage.
- Enumerations and typedef for defining standard data types.
- Design concepts like layered architectures and finite state machines.
- The contents and purpose of object files like .text, .data, .bss sections.
- AUTOSAR architecture with layers like MCAL, ECUAL, and services layer.
Kernel Recipes 2018 - 10 years of automated evolution in the Linux kernel - J...Anne Nicolas
The Coccinelle C-program matching and transformation tool was first released in 2008 to facilitate specification and automation in the evolution of Linux kernel code. The novel contribution of Coccinelle is to allow software developers to write code manipulation rules in terms of the code structure itself, via a generalization of the patch syntax. Over the years, Coccinelle has been extensively used in Linux kernel development, resulting in over 6000 commits to the Linux kernel, and has found its place as part of the Linux kernel development process. This talk will review the history of Coccinelle and its impact on the Linux kernel. It will also briefly present two newer tools, prequel and spinfer, that have built on the Coccinelle infrastructure.
The document discusses Visual Studio's live static code analysis feature. It explains that this feature analyzes code in real-time as it is written, without requiring compilation, to detect errors and potential issues based on installed code analyzers. The document demonstrates how to install and use code analyzers through examples, showing how analyzers detect issues and provide suggestions to fix problems directly in the code editor through light bulb notifications. It provides a case study walking through fixing various issues detected in sample code using suggestions from an analyzer to iteratively improve the code quality.
Threats to mobile devices are more prevalent and increasing in scope and complexity. Users of mobile devices desire to take full advantage of the features
available on those devices, but many of the features provide convenience and capability but sacrifice security. This best practices guide outlines steps the users can take to better protect personal devices and information.
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...SOFTTECHHUB
The choice of an operating system plays a pivotal role in shaping our computing experience. For decades, Microsoft's Windows has dominated the market, offering a familiar and widely adopted platform for personal and professional use. However, as technological advancements continue to push the boundaries of innovation, alternative operating systems have emerged, challenging the status quo and offering users a fresh perspective on computing.
One such alternative that has garnered significant attention and acclaim is Nitrux Linux 3.5.0, a sleek, powerful, and user-friendly Linux distribution that promises to redefine the way we interact with our devices. With its focus on performance, security, and customization, Nitrux Linux presents a compelling case for those seeking to break free from the constraints of proprietary software and embrace the freedom and flexibility of open-source computing.
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?Speck&Tech
ABSTRACT: A prima vista, un mattoncino Lego e la backdoor XZ potrebbero avere in comune il fatto di essere entrambi blocchi di costruzione, o dipendenze di progetti creativi e software. La realtà è che un mattoncino Lego e il caso della backdoor XZ hanno molto di più di tutto ciò in comune.
Partecipate alla presentazione per immergervi in una storia di interoperabilità, standard e formati aperti, per poi discutere del ruolo importante che i contributori hanno in una comunità open source sostenibile.
BIO: Sostenitrice del software libero e dei formati standard e aperti. È stata un membro attivo dei progetti Fedora e openSUSE e ha co-fondato l'Associazione LibreItalia dove è stata coinvolta in diversi eventi, migrazioni e formazione relativi a LibreOffice. In precedenza ha lavorato a migrazioni e corsi di formazione su LibreOffice per diverse amministrazioni pubbliche e privati. Da gennaio 2020 lavora in SUSE come Software Release Engineer per Uyuni e SUSE Manager e quando non segue la sua passione per i computer e per Geeko coltiva la sua curiosità per l'astronomia (da cui deriva il suo nickname deneb_alpha).
Full-RAG: A modern architecture for hyper-personalizationZilliz
Mike Del Balso, CEO & Co-Founder at Tecton, presents "Full RAG," a novel approach to AI recommendation systems, aiming to push beyond the limitations of traditional models through a deep integration of contextual insights and real-time data, leveraging the Retrieval-Augmented Generation architecture. This talk will outline Full RAG's potential to significantly enhance personalization, address engineering challenges such as data management and model training, and introduce data enrichment with reranking as a key solution. Attendees will gain crucial insights into the importance of hyperpersonalization in AI, the capabilities of Full RAG for advanced personalization, and strategies for managing complex data integrations for deploying cutting-edge AI solutions.
Communications Mining Series - Zero to Hero - Session 1DianaGray10
This session provides introduction to UiPath Communication Mining, importance and platform overview. You will acquire a good understand of the phases in Communication Mining as we go over the platform with you. Topics covered:
• Communication Mining Overview
• Why is it important?
• How can it help today’s business and the benefits
• Phases in Communication Mining
• Demo on Platform overview
• Q/A
UiPath Test Automation using UiPath Test Suite series, part 5DianaGray10
Welcome to UiPath Test Automation using UiPath Test Suite series part 5. In this session, we will cover CI/CD with devops.
Topics covered:
CI/CD with in UiPath
End-to-end overview of CI/CD pipeline with Azure devops
Speaker:
Lyndsey Byblow, Test Suite Sales Engineer @ UiPath, Inc.
Pushing the limits of ePRTC: 100ns holdover for 100 daysAdtran
At WSTS 2024, Alon Stern explored the topic of parametric holdover and explained how recent research findings can be implemented in real-world PNT networks to achieve 100 nanoseconds of accuracy for up to 100 days.
UiPath Test Automation using UiPath Test Suite series, part 6DianaGray10
Welcome to UiPath Test Automation using UiPath Test Suite series part 6. In this session, we will cover Test Automation with generative AI and Open AI.
UiPath Test Automation with generative AI and Open AI webinar offers an in-depth exploration of leveraging cutting-edge technologies for test automation within the UiPath platform. Attendees will delve into the integration of generative AI, a test automation solution, with Open AI advanced natural language processing capabilities.
Throughout the session, participants will discover how this synergy empowers testers to automate repetitive tasks, enhance testing accuracy, and expedite the software testing life cycle. Topics covered include the seamless integration process, practical use cases, and the benefits of harnessing AI-driven automation for UiPath testing initiatives. By attending this webinar, testers, and automation professionals can gain valuable insights into harnessing the power of AI to optimize their test automation workflows within the UiPath ecosystem, ultimately driving efficiency and quality in software development processes.
What will you get from this session?
1. Insights into integrating generative AI.
2. Understanding how this integration enhances test automation within the UiPath platform
3. Practical demonstrations
4. Exploration of real-world use cases illustrating the benefits of AI-driven test automation for UiPath
Topics covered:
What is generative AI
Test Automation with generative AI and Open AI.
UiPath integration with generative AI
Speaker:
Deepak Rai, Automation Practice Lead, Boundaryless Group and UiPath MVP
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024Neo4j
Neha Bajwa, Vice President of Product Marketing, Neo4j
Join us as we explore breakthrough innovations enabled by interconnected data and AI. Discover firsthand how organizations use relationships in data to uncover contextual insights and solve our most pressing challenges – from optimizing supply chains, detecting fraud, and improving customer experiences to accelerating drug discoveries.
Introducing Milvus Lite: Easy-to-Install, Easy-to-Use vector database for you...Zilliz
Join us to introduce Milvus Lite, a vector database that can run on notebooks and laptops, share the same API with Milvus, and integrate with every popular GenAI framework. This webinar is perfect for developers seeking easy-to-use, well-integrated vector databases for their GenAI apps.
Dr. Sean Tan, Head of Data Science, Changi Airport Group
Discover how Changi Airport Group (CAG) leverages graph technologies and generative AI to revolutionize their search capabilities. This session delves into the unique search needs of CAG’s diverse passengers and customers, showcasing how graph data structures enhance the accuracy and relevance of AI-generated search results, mitigating the risk of “hallucinations” and improving the overall customer journey.
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfPaige Cruz
Monitoring and observability aren’t traditionally found in software curriculums and many of us cobble this knowledge together from whatever vendor or ecosystem we were first introduced to and whatever is a part of your current company’s observability stack.
While the dev and ops silo continues to crumble….many organizations still relegate monitoring & observability as the purview of ops, infra and SRE teams. This is a mistake - achieving a highly observable system requires collaboration up and down the stack.
I, a former op, would like to extend an invitation to all application developers to join the observability party will share these foundational concepts to build on:
Maruthi Prithivirajan, Head of ASEAN & IN Solution Architecture, Neo4j
Get an inside look at the latest Neo4j innovations that enable relationship-driven intelligence at scale. Learn more about the newest cloud integrations and product enhancements that make Neo4j an essential choice for developers building apps with interconnected data and generative AI.
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slackshyamraj55
Discover the seamless integration of RPA (Robotic Process Automation), COMPOSER, and APM with AWS IDP enhanced with Slack notifications. Explore how these technologies converge to streamline workflows, optimize performance, and ensure secure access, all while leveraging the power of AWS IDP and real-time communication via Slack notifications.
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
64-bit Loki
1. 64-bit Loki
Authors: Evgeniy Ryzhkov, Andrey Karpov, Andrei Alexandrescu, Peter Kummel, Rich Sposato,
Date: 25.09.2009
Abstract
The article is a report about testing of portability of Loki library with 64-bit systems with the help of
Viva64 code analyzer performed by OOO "Program Verification Systems" Company. It contains
recommendations for users of the library. The article will be also useful for the users of other libraries
built on templates for it describes the peculiarities of analysis of such libraries.
Introduction
Loki library has been developed by Andrei Alexandrescu as part of the highly acclaimed book "Modern
C++ Design: Generic Programming and Design Patterns Applied". An abstract of the book declares: "This
book introduces the concept of generic components-reusable design templates that produce boilerplate
code for compiler consumption-all within C++. Generic components enable an easier and more seamless
transition from design to application code, generate code that better expresses the original design
intention, and support the reuse of design structures with minimal recoding."
OOO "Program Verification Systems" Company creating Viva64 code analyzer for developing 64-bit
applications participates actively in communication with the authors of various software projects. Once
one of Loki project administrators, Rich Sposato, asked us to check the code of the library for portability
to 64-bit systems with the help of our code analyzer Viva64. The Loki library is known for using the most
powerful and up-to-date abilities of C++ language; so if Viva64 managed Loki then it can easily manage
simpler projects.
We should notice that this article is based on the Loki version of May 2009 (it is more modern than the
official version of that time Loki 0.1.7), so the stated problems will be removed in further Loki versions.
So, we downloaded the latest version of Loki from the SVN repository on SourceForge and set to work.
Building of the 64-bit version of Loki in Microsoft Visual Studio 2005
Viva64 code analyzer integrates into Microsoft Visual Studio development environment, that's why it
would be sensible to build a version of Loki for this particular environment. Loki package contains ready
files of solutions for Visual Studio 2005 and Visual Studio 2008. But now, in May 2009, these solutions
contain only 32-bit configurations. That's why we needed to create configurations for x64 platform in
Visual Studio. After adding the necessary configurations we could launch compilation of the 64-bit
version.
Loki library is intended for operating on many various platforms and is built with the help of many most
popular compilers. It explains why the 64-bit Loki version has been compiled nearly at once. The Loki
library is actually only one of 20 projects in the most recent version of Loki. The other 19 projects are
test programs which exercise various parts of Loki to demonstrate the code compiles and runs correctly.
By including so many test programs with Loki, the programmers can provide guarantees for much of
2. Loki's functionality despite the complexity of the Loki source code. Out of 20 projects in the solution
only SafeFormat failed to build:
========== Build: 19 succeeded, 1 failed, 0 up-to-date, 0 skipped
==========
------ Build started: Project: SafeFormat, Configuration: Debug x64 --
----
Compiling...
main.cpp
.main.cpp(255) : error C3066: there are multiple ways
that an object of this type can be called with these arguments
....includeloki/SafeFormat.h(109): could be
'Loki::PrintfState<Device,Char>
&Loki::PrintfState<Device,Char>::operator ()(bool)'
...
while trying to match the argument list '(UInt)'
The text of the error is abridged a bit for it would take the whole page in a full form. Let's consider the
code causing the error:
void test_dword()
{
typedef signed int Int;
typedef unsigned int UInt;
typedef signed long Long;
typedef unsigned long ULong;
Int i(0);
UInt ui(0);
Long l(0);
ULong ul(0);
Printf("%d")(i);
Printf("%d")(ui); // the problem is in this line
Printf("%d")(l);
Printf("%d")(ul);
}
3. The PrintfState struct uses the LOKI_PRINTF_STATE_FORWARD macro to cast various parameter types
to unsigned long. We found one problem here where a 64 bit parameter may get sliced down to 32 bits
by this code snippet inside the file SafeFormat.h:
#if (defined(_WIN32) || defined(_WIN64))
LOKI_PRINTF_STATE_FORWARD(unsigned long)
#else
We recommend using this snippet to avoid slicing 64 bit types:
#if (defined(_WIN32) || defined(_WIN64))
#if (defined(_WIN64))
LOKI_PRINTF_STATE_FORWARD(unsigned int)
#endif
LOKI_PRINTF_STATE_FORWARD(unsigned long)
#else
After this single correction the compilation error disappears and all the 20 projects of the library
compiled with only some diagnostic warnings. One such warning tells us about a potentially unsafe
conversion of size_t type inside typicalUse() function in the file CachedFactoryTest.cpp:
// Registering objects
for(size_t i=0;i<objectKind;i++)
CC.Register(i, createProductNull);
The control variable (objectKind) of the loop is an unsigned type. After changing the type of the loop
counter to unsigned so it matches the type of the control variable, the warning disappears:
// Registering objects
for(unsigned i=0;i<objectKind;i++)
CC.Register(i, createProductNull);
After these small corrections the 64-bit library compiles successfully and does not show any diagnostic
warnings on 64-bit mode. But is the library's code actually correct? By running the many test projects
and seeing no incorrect results or assertion failures, we can confidently say the Loki library is correct.
We also used our code analyzer, Viva64, to perform static analysis of Loki.
Testing of the 64-bit Loki version with the help of Viva64
To make sure that Loki is compatible with 64-bit systems, let's perform analysis of the code using
Viva64. Viva64 code analyzer is intended for developing new 64-bit applications and porting of existing
32-bit ones on a 64-bit platform.
4. During the analysis of Loki, Viva64 detected 89 potentially unsafe syntactic constructions. It does not
mean Loki projects contain 89 errors related to 64-bit code, but that the developers should review these
89 places should be to understand if these are errors. Of course, we have studied these locations in the
code to ascertain if there are actual errors. Many of the 89 locations are inside test projects rather than
inside Loki itself.
1 Incorrectly used constant LONG_MIN
Let's begin with an error relating to the incorrectly used constant LONG_MIN in the following function:
char* RenderWithoutSign(LOKI_SAFEFORMAT_SIGNED_LONG n,
char* bufLast, unsigned int base, bool uppercase)
It is located in the file SafeFormat.h. The problem is in this line:
if (n != LONG_MIN) {
LOKI_SAFEFORMAT_SIGNED_LONG type is defined as a type capable of storing 64-bit values in a 64-bit
system. In Unix-systems (with LP64 data model) long type is used for this purpose. But in 64-bit
Windows-systems (LLP64 data model) long type remained 32-bit. That's why
LOKI_SAFEFORMAT_SIGNED_LONG type is defined in Loki in this way:
#if defined(_WIN32) || defined(_WIN64)
#define LOKI_SAFEFORMAT_SIGNED_LONG intptr_t
#define LOKI_SAFEFORMAT_UNSIGNED_LONG uintptr_t
#else
#define LOKI_SAFEFORMAT_SIGNED_LONG signed long
#define LOKI_SAFEFORMAT_UNSIGNED_LONG unsigned long
#endif
As long type remained 32-bit in 64-bit Windows-systems, LONG_MIN constant defines the minimum
value of the 32-bit variable. This means that using it is incorrect when operating 64-bit types (in this case
intptr_t). A strongly recommended solution is to use your own constant so you can guarantee its value
remains the same for all platforms, or so you can control its value per platform rather than relying on
the compiler. One possible correction is as follows:
#if defined(_WIN32) || defined(_WIN64)
# define LOKI_SAFEFORMAT_SIGNED_LONG intptr_t
#if defined(_WIN64)
# define LOKI_SAFEFORMAT_SIGNED_LONG_MIN_VALUE LLONG_MIN
# define LOKI_SAFEFORMAT_SIGNED_LONG_MAX_VALUE LLONG_MAX
#else
# define LOKI_SAFEFORMAT_SIGNED_LONG_MIN_VALUE LONG_MIN
5. # define LOKI_SAFEFORMAT_SIGNED_LONG_MAX_VALUE LONG_MAX
#endif
...
#else
# define LOKI_SAFEFORMAT_SIGNED_LONG signed long
# define LOKI_SAFEFORMAT_SIGNED_LONG_MIN_VALUE LONG_MIN
# define LOKI_SAFEFORMAT_SIGNED_LONG_MAX_VALUE LONG_MAX
...
#endif
Consequently, the line
if (n != LONG_MIN) {
must be replaced with
if (n != LOKI_SAFEFORMAT_SIGNED_LONG_MIN_VALUE) {
Fortunately, the creators of Loki library must be praised because this is the only line needing this
correction. All the other comments described further may be interesting but they are not important.
2 Some types of magic numbers - errors or not?
Many of the problems detected by the Viva64 analyzer in Loki are because the lines seem to contain
magic numbers. From the viewpoint of migration of code from a 32-bit platform on a 64-bit one, some
numbers are the most dangerous. Perhaps, a programmer wants to have a definite size of a data type in
some code section and this may cause a problem. Those who look through the warnings of the code
analyzer often complain that they are irrelevant. Really, why should the code analyzer about number 4
in lines like these?
::Loki::ScopeGuard guard4 = ::Loki::MakeGuard( &HasFour, 1, 2, 3, 4 );
::Loki::ScopeGuard guard5 = ::Loki::MakeGuard( &HasFive, 1, 2, 3, 4, 5
);
Sometimes there appear such constructions that must be studied very thoroughly. For example, in the
file SafeFormatmain.cpp we see the code:
case 'X':
// TestCase(formatSpec, RandomInt(-10000, 10000));
// don't test negative values on 64bit systems, because
// snprintf does not support 64 Bit values
TestCase(formatSpec,
RandomInt( -10000 * (sizeof(size_t)>4 ? 0 : 1) , 10000));
6. break;
case 'e':
Of course, this particular use of a magic number is not an actual problem, but detecting and diagnosing
magic numbers helps make the code more portable from one operating system to another and from 32
bits to 64 bits.
3 Addition of int to a pointer as a potential error
The file flexsimplestringstorage.h contains the function:
void resize(size_type newSize, E fill)
{
const int delta = int(newSize - size());
if (delta == 0) return;
if (delta > 0)
{
if (newSize > capacity())
{
reserve(newSize);
}
E* e = &*end();
flex_string_details::pod_fill(e, e + delta, fill);
}
pData_->pEnd_ = pData_->buffer_ + newSize;
}
Viva64 analyzer warns about a potential problem here:
flex_string_details::pod_fill(e, e + delta, fill);
The defect occurs in adding, delta, a variable of int type, to e, a pointer. This is a potential problem since
the pod_fill function will not be able to process a data size of more than 2 GB (INT_MAX characters).
This particular instance is not a no problem for there are hardly any lines that occupy more than 2 GB.
Even so, it is better to change delta from an int type to a ptrdiff_t type:
const ptrdiff_t delta = ptrdiff_t(newSize - size());
4 Using int for indexing arrays is incorrect
To access very large data arrays - more than INT_MAX elements - we recommend using types ptrdiff_t
or size_t instead of unsigned int or unsigned long. The file SmallObjSmallObjBench.cpp contains a large
7. macro LOKI_SMALLOBJ_BENCH_ARRAY in which an int is used to index an array since compilers often
use 32 bit variables for ints, but must use an appropriately sized data type for size_t.
5 Right arguments of functions
The file CachedFactoryCachedFactoryTest.cpp contains the following function:
template< class Cache >
milliSec typicalUse(Cache &CC, unsigned objectKind,
unsigned maxObjectCount, unsigned maxIteration)
We recommend using the size_t type for the objectKind parameter, but as this code exists only in a test
project, the code does not affect the Loki library itself.
Loki library is compatible with 64-bit systems - does it mean that we can
say the same about a program using it?
All the few problems of Loki library described above are easy to correct. Does that mean that if Loki
does not contain any 64-bit problems (and this is true) than any application using this library is also safe
from the viewpoint of 64-bit code? Unfortunately, it is not!
The point is that Loki library uses templates actively, so when the code analyzer examines a template
code sometimes it cannot detect a problem. To be absolutely sure the analyzer needs to perform
instancing of template classes and functions.
Let's give an example that does not relate to Loki library. Among other problems Viva64 analyzer can
detect non-optimal data structures in code:
template <class T>
struct TClass
{
int m_a;
T m_b;
int m_c;
};
If T has int type here the structure is optimal. But if T has size_t type the structure will occupy 24 bytes
instead of possible 16 bytes. When there are many such objects, it is better to rewrite the code in this
way:
template <class T>
struct TClass
{
T m_b;
8. int m_a;
int m_c;
};
But the analyzer can check it only by instancing the template. That is, you cannot detect a problem
when there is only definition of a class in the header.
Another example, again not relating to Loki, concerns type conversion:
template<typename T1, typename T2>
class TemplateClass
{
public:
void test1()
{
m_a.m_value = m_b.m_value; // is there an error here?
}
private:
T1 m_a;
T2 m_b;
};
In this code the error of type conversion can or cannot occur depending on the parameters with which
instancing of TemplateClass template is performed. Without performing instancing, by simply analyzing
the function's code, the analyzer cannot detect an error.
The two examples of template classes described above do not relate to Loki library but they are
important for understanding the principles of code analyzers' operation. The peculiarity of template
libraries like Loki is that even if a library is completely compatible with 64-bit systems it does not mean
that the code using it is correct. This point changes completely the approach to verification of
applications. Unlike common (non-template) libraries when complete compatibility with 64-bit systems
is enough to make sure that the whole application is correct, in case of template libraries you cannot be
sure about it.
All this means that although Loki library does not contain problems relating to 64-bit code, a user
application which uses it must be tested by the code analyzer additionally to see if there are such
problems, for errors depend on the parameters with which instancing of templates is performed.
Conclusion
The results of testing Loki library on compatibility with 64-bit systems performed by the workers of OOO
"Program Verification Systems" Company allowed us to draw the following conclusions:
9. The library is fully compatible with 64-bit systems and does not contain potential errors. The errors
stated in this article are likely to be corrected very easily.
Viva64 code analyzer intended for developing 64-bit applications and porting existing 32-bit ones turned
out to be very efficient when testing a complicated template code of the library. It proves a very good
quality of the code analyzer.
Although Loki library does not contain 64-bit problems they can occur in user applications using Loki. As
the end code depends on the parameters with which templates have been instanced, it is necessary to
test user applications with the help of the code analyzer. Only then you can be sure that the user
application is compatible with 64-bit systems.
Acknowledgements
We would like to thank the following people who assisted us with our analysis of Loki library, or
reviewed our work on Loki:
• We thank Program Verification Systems technical team who reviewed Loki library and carried
out verification of its 64-bit compliance: Andrey Karpov and Evgeniy Ryzhkov.
• We thank Loki team: Andrei Alexandrescu, Peter Kummel, and Rich Sposato for cooperation and
for checking our article, editing it and providing valuable advice.
• We are glad that Rich Sposato expressed the will of working together in future and we would
like to cooperate in future with the team of Loki developers.
References
1. Loki Library. http://www.viva64.com/go.php?url=515.
2. Viva64 Tool. http://www.viva64.com/viva64-tool.