Checking C++ codes for compatibility with operator overloading

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...

Full description

Saved in:
Bibliographic Details
Published in2015 IEEE 15th International Working Conference on Source Code Analysis and Manipulation (SCAM) pp. 91 - 100
Main Authors Huck, Alexander, Bischof, Christian, Utke, Jean
Format Conference Proceeding
LanguageEnglish
Published IEEE 01.09.2015
Subjects
Online AccessGet full text
DOI10.1109/SCAM.2015.7335405

Cover

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.
AbstractList 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.
Author Bischof, Christian
Huck, Alexander
Utke, Jean
Author_xml – sequence: 1
  givenname: Alexander
  surname: Huck
  fullname: Huck, Alexander
  email: alexander.hueck@sc.tu-darmstadt.de
  organization: Inst. of Sci. Comput., Tech. Univ. Darmstadt, Darmstadt, Germany
– sequence: 2
  givenname: Christian
  surname: Bischof
  fullname: Bischof, Christian
  email: christian.bischof@sc.tu-darmstadt.de
  organization: Inst. of Sci. Comput., Tech. Univ. Darmstadt, Darmstadt, Germany
– sequence: 3
  givenname: Jean
  surname: Utke
  fullname: Utke, Jean
  email: jutke@allstate.com
  organization: Quantitative Res. & Analytics, Allstate Insurance Co., USA
BookMark eNotj11LwzAYhSMo6OZ-gHjT-9H6pkma5EYYxS-YeKFej3y8ccGuKWlR9u8tuKtz4PA8cBbkvE89EnJDoaIU9N17u3mtaqCikowJDuKMLChvJJOi1vUlWY1jtMAAtK65vCL37R7dd-y_ina9LlzyOBYh5bkdBjNFG7s4HYvfOO2LNGA207ylH8xdMn6mrslFMN2Iq1Muyefjw0f7XG7fnl7azbaMtGZT6YOwqpHoZQCDDaiguPOmCcxzpazg1ju0VoJFJbXzIoTgg9XMOAZuVizJ7b83IuJuyPFg8nF3usj-AGJcSok
ContentType Conference Proceeding
DBID 6IE
6IL
CBEJK
RIE
RIL
DOI 10.1109/SCAM.2015.7335405
DatabaseName IEEE Electronic Library (IEL) Conference Proceedings
IEEE Xplore POP ALL
IEEE Xplore All Conference Proceedings
IEEE/IET Electronic Library
IEEE Proceedings Order Plans (POP All) 1998-Present
DatabaseTitleList
Database_xml – sequence: 1
  dbid: RIE
  name: IEEE Electronic Library (IEL)
  url: https://proxy.k.utb.cz/login?url=https://ieeexplore.ieee.org/
  sourceTypes: Publisher
DeliveryMethod fulltext_linktorsrc
EISBN 1467375292
9781467375290
EndPage 100
ExternalDocumentID 7335405
Genre orig-research
GroupedDBID 6IE
6IL
ALMA_UNASSIGNED_HOLDINGS
CBEJK
RIB
RIC
RIE
RIL
ID FETCH-LOGICAL-i123t-df5b867ed7f0ae608f84cda6f3d488b54bdcebb70be879cd5fffdfb93ac30c123
IEDL.DBID RIE
IngestDate Wed Dec 20 05:19:05 EST 2023
IsPeerReviewed false
IsScholarly false
Language English
LinkModel DirectLink
MergedId FETCHMERGED-LOGICAL-i123t-df5b867ed7f0ae608f84cda6f3d488b54bdcebb70be879cd5fffdfb93ac30c123
PageCount 10
ParticipantIDs ieee_primary_7335405
PublicationCentury 2000
PublicationDate 20150901
PublicationDateYYYYMMDD 2015-09-01
PublicationDate_xml – month: 09
  year: 2015
  text: 20150901
  day: 01
PublicationDecade 2010
PublicationTitle 2015 IEEE 15th International Working Conference on Source Code Analysis and Manipulation (SCAM)
PublicationTitleAbbrev SCAM
PublicationYear 2015
Publisher IEEE
Publisher_xml – name: IEEE
SSID ssib030099247
Score 1.5923773
Snippet Operator overloading allows the semantic extension of existing code without the need for sweeping code changes. For example, automatic differentiation tools in...
SourceID ieee
SourceType Publisher
StartPage 91
SubjectTerms Context
Encapsulation
Libraries
Semantics
Software packages
Title Checking C++ codes for compatibility with operator overloading
URI https://ieeexplore.ieee.org/document/7335405
hasFullText 1
inHoldings 1
isFullTextHit
isPrint
link http://utb.summon.serialssolutions.com/2.0.0/link/0/eLvHCXMwjV3LSgMxFA1tV65UWvFNFu5qprF5TTaCDJYiVAQtdFfyRFE6pU4X-vUmmWlFceFmCAPJTJ735txzEgAuMFPBihOJgvNgEeUKI8mZRVLxoQubZsJVxDsm93w8pXczNmuBy60WxjmXyGcui8kUy7elWUeobCBIRClYG7SFkLVWazN2SHR1hlQ0gcsrLAePxc0kcrdY1uT7cYFKsh-jXTDZfLmmjbxm60pn5vPXoYz__bU90PtW6sGHrQ3aBy236ILr4tmZCIHDot-HUbT-DoNvChPfvKrpsB8wIrCwXLoUZ4eRyflWJkJ9D0xHt0_FGDX3JKCX0MwVsp7pnAtnhcfKcZz7nBqruCc2TE_NqLbGaS2wdrmQxjLvvfVaEmUINqGIA9BZlAt3CKBmLIp5PQkLIdXGahF2sJ5hQw224XkEurHu82V9FMa8qfbx369PwE5s_5qSdQo61WrtzoINr_R56rwvvJKc5A
linkProvider IEEE
linkToHtml http://utb.summon.serialssolutions.com/2.0.0/link/0/eLvHCXMwjV3NS8MwFH_MedCTyiZ-m4O3mS4uTdJeBCmOqesQ3GC30XyhKOvQ7qB_vUlbJ4oHL6UU0ny2773f-_0SgDPCMmfFaYyd86BxyDOCY840jjPeMy5opjzzeEc64oNJeDtl0wacr7QwxpiSfGYCf1vm8nWulh4q6wrqUQq2BuvMRRWiUmt9rR7qnZ1eKOrU5QWJuw_JVerZWyyoS_44QqW0IP0tSL_qrogjz8GykIH6-LUt438btw3tb60eul9ZoR1omHkLLpNHozwIjpJOB3nZ-hty3ikqGedFRYh9Rx6DRfnClJl25LmcL3lJqW_DpH89Tga4PikBP7mBLrC2TEZcGC0syQwnkY1CpTNuqXYfqGSh1MpIKYg0kYiVZtZabWVMM0WJcq_YheY8n5s9QJIxL-e11P0KQ6m0FC6GtYyoUBHtrvvQ8n2fLarNMGZ1tw_-fnwKG4NxOpwNb0Z3h7Dp56IiaB1Bs3hdmmNn0Qt5Uk7kJyquoDU
openUrl ctx_ver=Z39.88-2004&ctx_enc=info%3Aofi%2Fenc%3AUTF-8&rfr_id=info%3Asid%2Fsummon.serialssolutions.com&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&rft.genre=proceeding&rft.title=2015+IEEE+15th+International+Working+Conference+on+Source+Code+Analysis+and+Manipulation+%28SCAM%29&rft.atitle=Checking+C%2B%2B+codes+for+compatibility+with+operator+overloading&rft.au=Huck%2C+Alexander&rft.au=Bischof%2C+Christian&rft.au=Utke%2C+Jean&rft.date=2015-09-01&rft.pub=IEEE&rft.spage=91&rft.epage=100&rft_id=info:doi/10.1109%2FSCAM.2015.7335405&rft.externalDocID=7335405