[go: up one dir, main page]
More Web Proxy on the site http://driver.im/ skip to main content
10.1145/2801081.2801114acmotherconferencesArticle/Chapter ViewAbstractPublication PagesbciConference Proceedingsconference-collections
short-paper

Life without implicit casts: safe type system in C++

Published: 02 September 2015 Publication History

Abstract

This paper contains the findings about our ongoing research to make safe type system in C++ to avoid unwanted implicit casts. Our related research revealed vulnerabilities in current mainstream programming languages, and gave recommendations for coding styles and designing a new programming language.
The C++ language allows implicit conversions between basic built-in types as well as user-defined types with conversion operators and implicit constructors. This feature is occasionally used, but in most of the cases is a harmful construction. To avoid the unwanted implicit casts, we introduce a new wrapper template class which hides the wrapped concrete type (which usually is a basic type), and automatically defines the required constructors and operators. The wrapper can also be used with various user-defined types.
In this paper we present some code snippets, which use our wrapper class to eliminate implicit casts. Through the examples, we show the advantages of our approach, confirming with the experiences of other languages without implicit casts.

References

[1]
A. Alexandrescu. Modern C++ Design: Generic Programming and Design Patterns Applied. Addison-Wesley, Boston, MA, 2001.
[2]
Á. Baráth. Welltype, 2014-2015. http://baratharon.web.elte.hu/welltype.
[3]
Á. Baráth and Z. Porkoláb. Towards safer programming language constructs. In 10th Joint Conference on Mathematics and Computer Science, page 25, May 2014.
[4]
K. Czarnecki and U. W. Eisenecker. Generative Programming: Methods, Tools, and Applications. ACM Press/Addison-Wesley Publishing Co., New York, NY, USA, 2000.
[5]
M. A. Ellis and B. Stroustrup. The Annotated C++ Reference Manual (pp. 45--82, 95--162). Addison-Wesley, 1990.
[6]
S. Meyers. Effective Modern C++: 42 Specific Ways to Improve Your Use of C++11 and C++14. O'Reilly Media, 2014.
[7]
N. Pataki, Z. Szűgyi, and G. Dévai. C++ standard template library in a safer way. In Proc. of Workshop on Generative Technologies 2010 (WGT 2010), pages 46--55, 2010.
[8]
B. Stroustrup. The C++ Programming Language, 4th Edition (Part III). Addison-Wesley Professional, 2013.
[9]
T. Veldhuizen. Expression templates. C++ Report, 7(5):26--31, 1995.
[10]
T. Veldhuizen. Using c++ template metaprograms. C++ Report, 7(4):36--43, 1995.

Cited By

View all
  • (2022)Flexible semi-automatic support for type migration of primitives for C/C++ programs2022 IEEE International Conference on Software Analysis, Evolution and Reengineering (SANER)10.1109/SANER53432.2022.00106(878-889)Online publication date: Mar-2022
  • (2022)Practical heuristics to improve precision for erroneous function argument swapping detection in C and C++Journal of Systems and Software10.1016/j.jss.2021.111048181:COnline publication date: 22-Apr-2022
  • (2020)The Role of Implicit Conversions in Erroneous Function Argument Swapping in C++2020 IEEE 20th International Working Conference on Source Code Analysis and Manipulation (SCAM)10.1109/SCAM51674.2020.00028(203-214)Online publication date: Sep-2020

Recommendations

Comments

Please enable JavaScript to view thecomments powered by Disqus.

Information & Contributors

Information

Published In

cover image ACM Other conferences
BCI '15: Proceedings of the 7th Balkan Conference on Informatics Conference
September 2015
293 pages
ISBN:9781450333351
DOI:10.1145/2801081
Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than ACM must be honored. Abstracting with credit is permitted. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from [email protected]

In-Cooperation

  • UCV: University of Craiova

Publisher

Association for Computing Machinery

New York, NY, United States

Publication History

Published: 02 September 2015

Permissions

Request permissions for this article.

Check for updates

Author Tags

  1. C++
  2. C++11
  3. implicit cast
  4. safe type system
  5. template
  6. type system
  7. wrapper class

Qualifiers

  • Short-paper
  • Research
  • Refereed limited

Conference

BCI '15
BCI '15: 7th Balkan Conference in Informatics
September 2 - 4, 2015
Craiova, Romania

Acceptance Rates

BCI '15 Paper Acceptance Rate 32 of 74 submissions, 43%;
Overall Acceptance Rate 97 of 250 submissions, 39%

Contributors

Other Metrics

Bibliometrics & Citations

Bibliometrics

Article Metrics

  • Downloads (Last 12 months)4
  • Downloads (Last 6 weeks)0
Reflects downloads up to 09 Jan 2025

Other Metrics

Citations

Cited By

View all
  • (2022)Flexible semi-automatic support for type migration of primitives for C/C++ programs2022 IEEE International Conference on Software Analysis, Evolution and Reengineering (SANER)10.1109/SANER53432.2022.00106(878-889)Online publication date: Mar-2022
  • (2022)Practical heuristics to improve precision for erroneous function argument swapping detection in C and C++Journal of Systems and Software10.1016/j.jss.2021.111048181:COnline publication date: 22-Apr-2022
  • (2020)The Role of Implicit Conversions in Erroneous Function Argument Swapping in C++2020 IEEE 20th International Working Conference on Source Code Analysis and Manipulation (SCAM)10.1109/SCAM51674.2020.00028(203-214)Online publication date: Sep-2020

View Options

Login options

View options

PDF

View or Download as a PDF file.

PDF

eReader

View online with eReader.

eReader

Media

Figures

Other

Tables

Share

Share

Share this Publication link

Share on social media