Early Detection of Type Errors in C plus plus Templates

被引:3
|
作者
Chen, Sheng [1 ]
Erwig, Martin [1 ]
机构
[1] Oregon State Univ, Sch EECS, Corvallis, OR 97331 USA
基金
美国国家科学基金会;
关键词
Metaprogramming; type systems; type reflection; choice types; C plus plus Templates; SAFE;
D O I
10.1145/2543728.2543731
中图分类号
TP31 [计算机软件];
学科分类号
081202 ; 0835 ;
摘要
Current C++ implementations typecheck templates in two phases: Before instantiation, those parts of the template are checked that do not depend on template parameters, while the checking of the remaining parts is delayed until template instantiation time when the template arguments become available. This approach is problematic because it causes two major usability problems. First, it prevents library developers to provide guarantees about the type correctness for modules involving templates. Second, it can lead, through the incorrect use of template functions, to inscrutable error messages. Moreover, errors are often reported far away from the source of the program fault. To address this problem, we have developed a type system for Garcia's type-reflective calculus that allows a more precise characterization of types and thus a better utilization of type information within template definitions. This type system allows the static detection of many type errors that could previously only be detected after template instantiation. The additional precision and earlier detection time is achieved through the use of so-called "choice types" and corresponding typing rules that support the static reasoning about underspecified template types. The main contribution of this paper is a guarantee of the type safety of C++ templates (general definitions with specializations) since we can show that well-typed templates only generate well-typed object programs.
引用
收藏
页码:133 / 144
页数:12
相关论文
共 50 条
  • [41] C plus plus constructors
    Plochan, F
    [J]. DR DOBBS JOURNAL, 1997, 22 (08): : 10 - +
  • [42] Synchronising C/C plus plus and POWER
    Sarkar, Susmit
    Memarian, Kayvan
    Owens, Scott
    Batty, Mark
    Sewell, Peter
    Maranget, Luc
    Alglave, Jade
    Williams, Derek
    [J]. ACM SIGPLAN NOTICES, 2012, 47 (06) : 311 - 321
  • [43] CenterNet plus plus for Object Detection
    Duan, Kaiwen
    Bai, Song
    Xie, Lingxi
    Qi, Honggang
    Huang, Qingming
    Tian, Qi
    [J]. IEEE TRANSACTIONS ON PATTERN ANALYSIS AND MACHINE INTELLIGENCE, 2024, 46 (05) : 3509 - 3521
  • [44] UPC plus plus : A PGAS Extension for C plus
    Zheng, Yili
    Kamil, Amir
    Driscoll, Michael B.
    Shan, Hongzhang
    Yelick, Katherine
    [J]. 2014 IEEE 28TH INTERNATIONAL PARALLEL AND DISTRIBUTED PROCESSING SYMPOSIUM, 2014,
  • [45] ROC plus plus : Robust Optimization in C plus
    Vayanos, Phebe
    Jin, Qing
    Elissaios, George
    [J]. INFORMS JOURNAL ON COMPUTING, 2022, 34 (06) : 2873 - 2888
  • [46] A Dynamic Detection Method to C/C plus plus Programs Memory Vulnerabilities Based on Pointer Analysis
    Ma, Rui
    Chen, Lingkui
    Hu, Changzhen
    Xue, Jingfeng
    Zhao, Xiaolin
    [J]. 2013 IEEE 11TH INTERNATIONAL CONFERENCE ON DEPENDABLE, AUTONOMIC AND SECURE COMPUTING (DASC), 2013, : 52 - 57
  • [47] CFIXX: Object Type Integrity for C plus
    Burow, Nathan
    McKee, Derrick
    Carr, Scott A.
    Payer, Mathias
    [J]. 25TH ANNUAL NETWORK AND DISTRIBUTED SYSTEM SECURITY SYMPOSIUM (NDSS 2018), 2018,
  • [48] Open and Efficient Type Switch for C plus
    Solodkyy, Yuriy
    Dos Reis, Gabriel
    Stroustrup, Bjarne
    [J]. ACM SIGPLAN NOTICES, 2012, 47 (10) : 963 - 982
  • [49] Flexible semi-automatic support for type migration of primitives for C/C plus plus programs
    Szalay, Richard
    Porkolab, Zoltan
    [J]. 2022 IEEE INTERNATIONAL CONFERENCE ON SOFTWARE ANALYSIS, EVOLUTION AND REENGINEERING (SANER 2022), 2022, : 878 - 889
  • [50] Early detection of nonresponse to interferon plus ribavirin combination treatment of chronic hepatitis C
    Castro, FJ
    Esteban, JI
    Juárez, A
    Sauleda, S
    Viladomiu, L
    Martell, M
    Moreno, F
    Allende, H
    Esteban, R
    Guardia, J
    [J]. JOURNAL OF VIRAL HEPATITIS, 2002, 9 (03) : 202 - 207