TU Darmstadt / ULB / TUbiblio

Checking C++ Codes for Compatibility with Operator Overloading

Hück, Alexander and Bischof, Christian and Utke, Jean (2015):
Checking C++ Codes for Compatibility with Operator Overloading.
In: 2015 IEEE 15th International Working Conference on Source Code Analysis and Manipulation (SCAM), IEEE, pp. 91-100, 15, [Online-Edition: http://ieeexplore.ieee.org/servlet/opac?punumber=7321933],
[Article]

Abstract

Operator overloading allows the semantic extension of existing code without the need for sweeping code changes. For example, automatic differentiation tools in C++ commonly use this feature to enhance the code with additional derivative computation. To this end, a floating point data type is changed to a complex user-defined type. While conceptually straightforward, this type change often leads to compilation errors that can be tedious to decipher and resolve. This is due to the fact that the built-in floating point types in C++ are treated differently than user-defined types, and code constructs that are legal for floating point types can be a violation of the C++ standard for complex user-defined types. We identify and classify such problematic code constructs and suggest how the code can be changed to avoid these errors, while still allowing the use of operator overloading. To automatically flag such occurrences, we developed a Clang-based tool for the static analysis of C++ code based on our assessment of constructs problematic in operator overloading for numeric types. It automatically finds instances of problematic code locations and prints Lint-like warning messages. To showcase the relevance of this topic and the usefulness of our tool, we consider the basic routines of the OpenFOAM CFD software package, consisting of 1,476 C++ source and header files, for a total of over 150,000 lines of code. Altogether, we found 74 distinct occurrences of problematic code constructs in 21 files. As some of these files are included in over 400 different locations in the OpenFOAM base, errors in these files create a torrent of error messages that often are difficult to comprehend. In summary, the classification of problematic instances aids developers in writing numerical code that is fit for operator overloading and the tool helps programmers that augment legacy code in spotting problematic code constructs.

Item Type: Article
Erschienen: 2015
Creators: Hück, Alexander and Bischof, Christian and Utke, Jean
Title: Checking C++ Codes for Compatibility with Operator Overloading
Language: English
Abstract:

Operator overloading allows the semantic extension of existing code without the need for sweeping code changes. For example, automatic differentiation tools in C++ commonly use this feature to enhance the code with additional derivative computation. To this end, a floating point data type is changed to a complex user-defined type. While conceptually straightforward, this type change often leads to compilation errors that can be tedious to decipher and resolve. This is due to the fact that the built-in floating point types in C++ are treated differently than user-defined types, and code constructs that are legal for floating point types can be a violation of the C++ standard for complex user-defined types. We identify and classify such problematic code constructs and suggest how the code can be changed to avoid these errors, while still allowing the use of operator overloading. To automatically flag such occurrences, we developed a Clang-based tool for the static analysis of C++ code based on our assessment of constructs problematic in operator overloading for numeric types. It automatically finds instances of problematic code locations and prints Lint-like warning messages. To showcase the relevance of this topic and the usefulness of our tool, we consider the basic routines of the OpenFOAM CFD software package, consisting of 1,476 C++ source and header files, for a total of over 150,000 lines of code. Altogether, we found 74 distinct occurrences of problematic code constructs in 21 files. As some of these files are included in over 400 different locations in the OpenFOAM base, errors in these files create a torrent of error messages that often are difficult to comprehend. In summary, the classification of problematic instances aids developers in writing numerical code that is fit for operator overloading and the tool helps programmers that augment legacy code in spotting problematic code constructs.

Journal or Publication Title: 2015 IEEE 15th International Working Conference on Source Code Analysis and Manipulation (SCAM)
Title of Book: 2015 IEEE 15th International Working Conference on Source Code Analysis and Manipulation (SCAM)
Series Name: IEEE International Workshop on Source Code Analysis and Manipulation
Volume: 15
Publisher: IEEE
Divisions: 20 Department of Computer Science
20 Department of Computer Science > Scientific Computing
Zentrale Einrichtungen > University IT-Service and Computing Centre (HRZ) > Hochleistungsrechner
Zentrale Einrichtungen > University IT-Service and Computing Centre (HRZ)
Zentrale Einrichtungen
Event Title: 2015 IEEE 15th International Working Conference on Source Code Analysis and Manipulation (SCAM)
Event Location: Bremen, Germany
Event Dates: 27-28 Sept 2015
Date Deposited: 30 Sep 2015 08:51
Official URL: http://ieeexplore.ieee.org/servlet/opac?punumber=7321933
Identification Number: doi:10.1109/SCAM.2015.7335405
Related URLs:
Export:
Suche nach Titel in: TUfind oder in Google

Optionen (nur für Redakteure)

View Item View Item