SlideShare a Scribd company logo
© Perforce Software Inc. All Rights Reserved.
Coding Safe, Modern C++
with AUTOSAR Guidelines
2© Perforce Software Inc. All Rights Reserved.
Presenters
Richard Bellairs
Product Marketing Manager
Richard Corden
Lead Software Developer
3© Perforce Software Inc. All Rights Reserved.
Here’s What We’ll Cover Today
1
Introduction
to AUTOSAR
Guidelines
2
Key Features &
Recent Updates
3
What’s Next?
(AUTOSAR &
MISRA C++)
Introduction to the AUTOSAR Coding Guidelines
5© Perforce Software Inc. All Rights Reserved.
90% of innovations driven by electronics and software.
40% of vehicle development costs.
You need to manage complexity
and keep costs down.
Why AUTOSAR?
6© Perforce Software Inc. All Rights Reserved.
Standard Open Software Architecture
for Automotive ECUs
7© Perforce Software Inc. All Rights Reserved.
The Rise of C++
8© Perforce Software Inc. All Rights Reserved.
• Guidelines for the use of the C++14 language in critical
and safety-related systems.
What Are the AUTOSAR Coding Guidelines?
9© Perforce Software Inc. All Rights Reserved.
• MISRA C++:2008 was written for C++03.
• Language evolved.
• Compilers improved.
• Tools improved.
• ISO 26262 released.
• Body of knowledge expanded.
Why Use the AUTOSAR Guidelines?
Key Features of the Guidelines
11© Perforce Software Inc. All Rights Reserved.
• Rule A10-3-2: Virtual Functions
Changes to C++ Language
// Non-compliant
struct Base { virtual void f(); };
struct Derived : Base {
void f();
};
// Compliant
struct Base { virtual void f(); };
struct Derived : Base {
void f() override;
};
12© Perforce Software Inc. All Rights Reserved.
• Rule A8-4-1: Variadic Templates
Changes to C++ Language
// Non-compliant
void f9a(const char *s, ...)
{
// ...
}
// Compliant
template <typename First, typename... Rest>
void f9b(First const & first, Rest const & ... rest)
{
// ...
}
13© Perforce Software Inc. All Rights Reserved.
// Non-compliant
int32_t myInt{0};
for_each(v.begin(), v.end(), [&] (int32_t) {
myInt++;
});
//Compliant
myInt = 0;
for_each(v.begin(), v.end(), [&myInt] (int32_t rhs) {
myInt += rhs;
});
• Rule A5-1-2: Lambdas
• No implicit capture
Safe Usage of New C++ Features
14© Perforce Software Inc. All Rights Reserved.
Lambdas — Rule A5-1-2
void f8(std::vector<int> const & v1, std::vector<int> const & v2) {
int eS = 0;
for (auto e1 : v1) {
std::for_each (v2.begin ()
, v2.end ()
, [&](auto e2) { e1 += e1 * e2 ; });
}
}
15© Perforce Software Inc. All Rights Reserved.
void f8(std::vector<int> const & v1, std::vector<int> const & v2) {
int eS = 0;
for (auto e1 : v1) {
std::for_each (v2.begin ()
, v2.end ()
, [e1,&eS](auto e2) { e1 += e1 * e2 ; });
// ^
// Error
}
}
Lambdas — Rule A5-1-2 (Continued)
16© Perforce Software Inc. All Rights Reserved.
• Multi return:
• MISRA C++ “Single exit” rule
not included in AUTOSAR.
• A key rationale for SE/SE is to
ensure correct releasing of
resources.
Less Restrictive Guidelines
bool f1 (unsigned cnt) {
int * i = new int (10);
while (--cnt) {
if ( cnt == 27 ) {
delete i;
return false;
}
}
delete i;
return true;
}
17© Perforce Software Inc. All Rights Reserved.
Multi Return (Continued)
• Uses RAII
(Resource Acquisition
Is Initialization).
• Correct, even in
‘exceptional’
circumstances.
bool f2 (unsigned cnt) {
auto i { std::make_unique<int> (10) } ;
while (--cnt) {
if ( cnt == 27 ) {
return false;
}
}
return true;
}
AUTOSAR with RAII
18© Perforce Software Inc. All Rights Reserved.
Multi Return (Continued)
// Single Return
bool f3(std::string const & file1, std::string const & file2){
int result = false;
std::filebuf fromBuf;
if (fromBuf.open (file1, std::ios::in)){
std::filebuf outBuf;
if (outBuf.open (file2, std::ios::out)){
result = ...;
}
else{
result = ...;
}
}
else{
result = ...;
}
return result;
}
// Multi Return
bool f4(std::string const & file1, std::string const & file2){
std::filebuf fromBuf;
if (! fromBuf->open(file1, std::ios::in)) return false;
std::filebuf outBuf;
if (! outBuf->open(file2, std::ios::out)) return false;
//...
19© Perforce Software Inc. All Rights Reserved.
Who Should Use AUTOSAR?
Recent Updates to the Guidelines
21© Perforce Software Inc. All Rights Reserved.
Initial release
Evolution of the Guidelines
10 new rules
Traceability
updates
63 new rules
18 rules
removed
Traceability
updates
7 new rules
ISO 26262
traceability
17.03 17.10 18.03 18.10
22© Perforce Software Inc. All Rights Reserved.
• Chapter B.6 traces principles and
recommendations from:
• ISO 26262, Part 6, Section 8
(Software unit design and
implementation).
• It’s easier to demonstrate that by
following AUTOSAR you have
(partially) fulfilled specific ISO
26262 requirements.
ISO 26262 Traceability
23© Perforce Software Inc. All Rights Reserved.
Enforced By Static Code Analysis
Helix QAC — Core Functions
Detects coding defects.
Finds the most defects, with the
lowest number of false positives.
Detects rule violations.
The broadest and deepest coverage
of popular coding standards.
Calculates code quality metrics.
Supplies all commonly-used metrics,
with trend reporting.
Generates compliance reports.
Certified for safety-critical
development.
What’s Next?
26© Perforce Software Inc. All Rights Reserved.
AUTOSAR Guidelines and MISRA C++
• MISRA recently announced that it will integrate AUTOSAR
guidelines and MISRA C++ into one publication.
Why Helix QAC?
• Helix QAC aids in compliance with industry-specific safety and
security standards.
Helix QAC for Faster Compliance
Standard-specific compliance reports.
Independently certified.
Supports formal rule deviations
and compliance auditing.
• Helix QAC improves your code quality.
Helix QAC for Higher Quality
Report code metrics.
Remove more defects — earlier in your dev cycle.
Prioritize and assign fixes.
Report code quality trends.
• Helix QAC increases confidence in the safety, security, and reliability
of software-based systems.
Helix QAC for Accelerated Development
High speed analysis across multiple
processor cores.
Analyze very large codebases (millions
of lines of code, thousands of files).
Integrate with IDE, VCS, and build tools.
Spend less time finding and fixing bugs,
more time developing!
31© Perforce Software Inc. All Rights Reserved.
Recap
1
Introduction
to AUTOSAR
Guidelines
2
Key Features &
Recent Updates
3
What’s Next?
(AUTOSAR &
MISRA C++)
Questions?
Contact us to schedule a demo!
info@perforce.com
Follow us for news and insights!
Visit www.perforce.com

More Related Content

PDF
Automotive embedded systems part6 v2
PDF
Automotive embedded systems part1 v1
PDF
software engineering
PDF
PDF
C programming first_session
PDF
Automotive embedded systems part2 v1
PDF
Automotive embedded systems part5 v1
PDF
Automotive embedded systems part6 v1
Automotive embedded systems part6 v2
Automotive embedded systems part1 v1
software engineering
C programming first_session
Automotive embedded systems part2 v1
Automotive embedded systems part5 v1
Automotive embedded systems part6 v1

What's hot (20)

PDF
MISRA C in an ISO 26262 context
PPTX
ECU Flashing: Flash Bootloaders that Facilitate ECU Reprogramming
PPTX
SDLC vs STLC
PDF
Unit Testing vs Integration Testing
PPTX
Tools for Software Testing
PPTX
Istqb foundation level day 1
PPT
PDF
Introduction to software FMEA
PPTX
Embedded C workshop
PPTX
Software Testing - Part 1 (Techniques, Types, Levels, Methods, STLC, Bug Life...
PPT
Software System Engineering - Chapter 1
PPTX
Basics in software testing
PPT
Basic software-testing-concepts
PPTX
PPTX
Software testing tools (free and open source)
PPTX
Software Testing Introduction
PDF
Introduction to AUTOSAR BSW (Base Software) & RTE (Real-Time Environment)
PPTX
Embedded System Test Automation
PDF
Manual Testing real time questions .pdf
PDF
Why OutSystems
MISRA C in an ISO 26262 context
ECU Flashing: Flash Bootloaders that Facilitate ECU Reprogramming
SDLC vs STLC
Unit Testing vs Integration Testing
Tools for Software Testing
Istqb foundation level day 1
Introduction to software FMEA
Embedded C workshop
Software Testing - Part 1 (Techniques, Types, Levels, Methods, STLC, Bug Life...
Software System Engineering - Chapter 1
Basics in software testing
Basic software-testing-concepts
Software testing tools (free and open source)
Software Testing Introduction
Introduction to AUTOSAR BSW (Base Software) & RTE (Real-Time Environment)
Embedded System Test Automation
Manual Testing real time questions .pdf
Why OutSystems
Ad

Similar to Coding Safe Modern C++ With AUTOSAR Guidelines (20)

PPTX
Safety on the Max: How to Write Reliable C/C++ Code for Embedded Systems
PDF
Achieving Software Safety, Security, and Reliability Part 2
PDF
What's New in Helix QAC 2019.1
PPTX
Designing For Functional Safety? How to Apply a Coding Standard
PDF
Achieving Software Safety, Security, and Reliability Part 3: What Does the Fu...
PDF
Misra C2012 Guidelines For The Use Of The C Language In Critical Systems Moto...
PDF
Afry software safety ISO26262 (Embedded @ Gothenburg Meetup)
PDF
MISRA C 2012 Amendment 1 Additional security guidelines for MISRA C 2012 Moto...
PPTX
Navigating the jungle of Secure Coding Standards
PPTX
An Introduction to MISRA C:2012
PPTX
MISRA-C.pptx
PDF
Webinar misra and security
PDF
Achieve iso 26262 certification
PDF
Code Quality Management Best Practices
PDF
What Is MISRA and how to Cook It
PDF
Driving Risks Out of Embedded Automotive Software
PDF
MISRA C – Recent developments and a road map to the future
PDF
The c++coreguidelinesforsavercode
PDF
C++: a fast tour of a fast language
PDF
maXbox Starter 43 Work with Code Metrics ISO Standard
Safety on the Max: How to Write Reliable C/C++ Code for Embedded Systems
Achieving Software Safety, Security, and Reliability Part 2
What's New in Helix QAC 2019.1
Designing For Functional Safety? How to Apply a Coding Standard
Achieving Software Safety, Security, and Reliability Part 3: What Does the Fu...
Misra C2012 Guidelines For The Use Of The C Language In Critical Systems Moto...
Afry software safety ISO26262 (Embedded @ Gothenburg Meetup)
MISRA C 2012 Amendment 1 Additional security guidelines for MISRA C 2012 Moto...
Navigating the jungle of Secure Coding Standards
An Introduction to MISRA C:2012
MISRA-C.pptx
Webinar misra and security
Achieve iso 26262 certification
Code Quality Management Best Practices
What Is MISRA and how to Cook It
Driving Risks Out of Embedded Automotive Software
MISRA C – Recent developments and a road map to the future
The c++coreguidelinesforsavercode
C++: a fast tour of a fast language
maXbox Starter 43 Work with Code Metrics ISO Standard
Ad

More from Perforce (20)

PDF
How to Organize Game Developers With Different Planning Needs
PDF
Regulatory Traceability: How to Maintain Compliance, Quality, and Cost Effic...
PDF
Efficient Security Development and Testing Using Dynamic and Static Code Anal...
PDF
Understanding Compliant Workflow Enforcement SOPs
PDF
Branching Out: How To Automate Your Development Process
PDF
How to Do Code Reviews at Massive Scale For DevOps
PDF
How to Spark Joy In Your Product Backlog
PDF
Going Remote: Build Up Your Game Dev Team
PDF
Shift to Remote: How to Manage Your New Workflow
PPTX
Hybrid Development Methodology in a Regulated World
PPTX
Better, Faster, Easier: How to Make Git Really Work in the Enterprise
PDF
Easier Requirements Management Using Diagrams In Helix ALM
PDF
How To Master Your Mega Backlog
PDF
How to Scale With Helix Core and Microsoft Azure
PDF
Should You Break Up With Your Monolith?
PDF
Achieving Software Safety, Security, and Reliability Part 1: Common Industry ...
PDF
What's New in Helix ALM 2019.4
PDF
Free Yourself From the MS Office Prison
PDF
5 Ways to Accelerate Standards Compliance with Static Code Analysis
PDF
Scale Kanban Beyond Team Level
How to Organize Game Developers With Different Planning Needs
Regulatory Traceability: How to Maintain Compliance, Quality, and Cost Effic...
Efficient Security Development and Testing Using Dynamic and Static Code Anal...
Understanding Compliant Workflow Enforcement SOPs
Branching Out: How To Automate Your Development Process
How to Do Code Reviews at Massive Scale For DevOps
How to Spark Joy In Your Product Backlog
Going Remote: Build Up Your Game Dev Team
Shift to Remote: How to Manage Your New Workflow
Hybrid Development Methodology in a Regulated World
Better, Faster, Easier: How to Make Git Really Work in the Enterprise
Easier Requirements Management Using Diagrams In Helix ALM
How To Master Your Mega Backlog
How to Scale With Helix Core and Microsoft Azure
Should You Break Up With Your Monolith?
Achieving Software Safety, Security, and Reliability Part 1: Common Industry ...
What's New in Helix ALM 2019.4
Free Yourself From the MS Office Prison
5 Ways to Accelerate Standards Compliance with Static Code Analysis
Scale Kanban Beyond Team Level

Recently uploaded (20)

PDF
Flood Susceptibility Mapping Using Image-Based 2D-CNN Deep Learnin. Overview ...
PPTX
ai tools demonstartion for schools and inter college
PPTX
Online Work Permit System for Fast Permit Processing
PPTX
L1 - Introduction to python Backend.pptx
PDF
Softaken Excel to vCard Converter Software.pdf
PPTX
ManageIQ - Sprint 268 Review - Slide Deck
PDF
Wondershare Filmora 15 Crack With Activation Key [2025
PDF
Odoo Companies in India – Driving Business Transformation.pdf
PDF
Audit Checklist Design Aligning with ISO, IATF, and Industry Standards — Omne...
PPTX
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
PPTX
Transform Your Business with a Software ERP System
PDF
Design an Analysis of Algorithms I-SECS-1021-03
PDF
How Creative Agencies Leverage Project Management Software.pdf
PDF
How to Migrate SBCGlobal Email to Yahoo Easily
PDF
top salesforce developer skills in 2025.pdf
PDF
Upgrade and Innovation Strategies for SAP ERP Customers
PPTX
Introduction to Artificial Intelligence
PDF
AI in Product Development-omnex systems
PDF
How to Choose the Right IT Partner for Your Business in Malaysia
PDF
Which alternative to Crystal Reports is best for small or large businesses.pdf
Flood Susceptibility Mapping Using Image-Based 2D-CNN Deep Learnin. Overview ...
ai tools demonstartion for schools and inter college
Online Work Permit System for Fast Permit Processing
L1 - Introduction to python Backend.pptx
Softaken Excel to vCard Converter Software.pdf
ManageIQ - Sprint 268 Review - Slide Deck
Wondershare Filmora 15 Crack With Activation Key [2025
Odoo Companies in India – Driving Business Transformation.pdf
Audit Checklist Design Aligning with ISO, IATF, and Industry Standards — Omne...
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
Transform Your Business with a Software ERP System
Design an Analysis of Algorithms I-SECS-1021-03
How Creative Agencies Leverage Project Management Software.pdf
How to Migrate SBCGlobal Email to Yahoo Easily
top salesforce developer skills in 2025.pdf
Upgrade and Innovation Strategies for SAP ERP Customers
Introduction to Artificial Intelligence
AI in Product Development-omnex systems
How to Choose the Right IT Partner for Your Business in Malaysia
Which alternative to Crystal Reports is best for small or large businesses.pdf

Coding Safe Modern C++ With AUTOSAR Guidelines

  • 1. © Perforce Software Inc. All Rights Reserved. Coding Safe, Modern C++ with AUTOSAR Guidelines
  • 2. 2© Perforce Software Inc. All Rights Reserved. Presenters Richard Bellairs Product Marketing Manager Richard Corden Lead Software Developer
  • 3. 3© Perforce Software Inc. All Rights Reserved. Here’s What We’ll Cover Today 1 Introduction to AUTOSAR Guidelines 2 Key Features & Recent Updates 3 What’s Next? (AUTOSAR & MISRA C++)
  • 4. Introduction to the AUTOSAR Coding Guidelines
  • 5. 5© Perforce Software Inc. All Rights Reserved. 90% of innovations driven by electronics and software. 40% of vehicle development costs. You need to manage complexity and keep costs down. Why AUTOSAR?
  • 6. 6© Perforce Software Inc. All Rights Reserved. Standard Open Software Architecture for Automotive ECUs
  • 7. 7© Perforce Software Inc. All Rights Reserved. The Rise of C++
  • 8. 8© Perforce Software Inc. All Rights Reserved. • Guidelines for the use of the C++14 language in critical and safety-related systems. What Are the AUTOSAR Coding Guidelines?
  • 9. 9© Perforce Software Inc. All Rights Reserved. • MISRA C++:2008 was written for C++03. • Language evolved. • Compilers improved. • Tools improved. • ISO 26262 released. • Body of knowledge expanded. Why Use the AUTOSAR Guidelines?
  • 10. Key Features of the Guidelines
  • 11. 11© Perforce Software Inc. All Rights Reserved. • Rule A10-3-2: Virtual Functions Changes to C++ Language // Non-compliant struct Base { virtual void f(); }; struct Derived : Base { void f(); }; // Compliant struct Base { virtual void f(); }; struct Derived : Base { void f() override; };
  • 12. 12© Perforce Software Inc. All Rights Reserved. • Rule A8-4-1: Variadic Templates Changes to C++ Language // Non-compliant void f9a(const char *s, ...) { // ... } // Compliant template <typename First, typename... Rest> void f9b(First const & first, Rest const & ... rest) { // ... }
  • 13. 13© Perforce Software Inc. All Rights Reserved. // Non-compliant int32_t myInt{0}; for_each(v.begin(), v.end(), [&] (int32_t) { myInt++; }); //Compliant myInt = 0; for_each(v.begin(), v.end(), [&myInt] (int32_t rhs) { myInt += rhs; }); • Rule A5-1-2: Lambdas • No implicit capture Safe Usage of New C++ Features
  • 14. 14© Perforce Software Inc. All Rights Reserved. Lambdas — Rule A5-1-2 void f8(std::vector<int> const & v1, std::vector<int> const & v2) { int eS = 0; for (auto e1 : v1) { std::for_each (v2.begin () , v2.end () , [&](auto e2) { e1 += e1 * e2 ; }); } }
  • 15. 15© Perforce Software Inc. All Rights Reserved. void f8(std::vector<int> const & v1, std::vector<int> const & v2) { int eS = 0; for (auto e1 : v1) { std::for_each (v2.begin () , v2.end () , [e1,&eS](auto e2) { e1 += e1 * e2 ; }); // ^ // Error } } Lambdas — Rule A5-1-2 (Continued)
  • 16. 16© Perforce Software Inc. All Rights Reserved. • Multi return: • MISRA C++ “Single exit” rule not included in AUTOSAR. • A key rationale for SE/SE is to ensure correct releasing of resources. Less Restrictive Guidelines bool f1 (unsigned cnt) { int * i = new int (10); while (--cnt) { if ( cnt == 27 ) { delete i; return false; } } delete i; return true; }
  • 17. 17© Perforce Software Inc. All Rights Reserved. Multi Return (Continued) • Uses RAII (Resource Acquisition Is Initialization). • Correct, even in ‘exceptional’ circumstances. bool f2 (unsigned cnt) { auto i { std::make_unique<int> (10) } ; while (--cnt) { if ( cnt == 27 ) { return false; } } return true; } AUTOSAR with RAII
  • 18. 18© Perforce Software Inc. All Rights Reserved. Multi Return (Continued) // Single Return bool f3(std::string const & file1, std::string const & file2){ int result = false; std::filebuf fromBuf; if (fromBuf.open (file1, std::ios::in)){ std::filebuf outBuf; if (outBuf.open (file2, std::ios::out)){ result = ...; } else{ result = ...; } } else{ result = ...; } return result; } // Multi Return bool f4(std::string const & file1, std::string const & file2){ std::filebuf fromBuf; if (! fromBuf->open(file1, std::ios::in)) return false; std::filebuf outBuf; if (! outBuf->open(file2, std::ios::out)) return false; //...
  • 19. 19© Perforce Software Inc. All Rights Reserved. Who Should Use AUTOSAR?
  • 20. Recent Updates to the Guidelines
  • 21. 21© Perforce Software Inc. All Rights Reserved. Initial release Evolution of the Guidelines 10 new rules Traceability updates 63 new rules 18 rules removed Traceability updates 7 new rules ISO 26262 traceability 17.03 17.10 18.03 18.10
  • 22. 22© Perforce Software Inc. All Rights Reserved. • Chapter B.6 traces principles and recommendations from: • ISO 26262, Part 6, Section 8 (Software unit design and implementation). • It’s easier to demonstrate that by following AUTOSAR you have (partially) fulfilled specific ISO 26262 requirements. ISO 26262 Traceability
  • 23. 23© Perforce Software Inc. All Rights Reserved. Enforced By Static Code Analysis
  • 24. Helix QAC — Core Functions Detects coding defects. Finds the most defects, with the lowest number of false positives. Detects rule violations. The broadest and deepest coverage of popular coding standards. Calculates code quality metrics. Supplies all commonly-used metrics, with trend reporting. Generates compliance reports. Certified for safety-critical development.
  • 26. 26© Perforce Software Inc. All Rights Reserved. AUTOSAR Guidelines and MISRA C++ • MISRA recently announced that it will integrate AUTOSAR guidelines and MISRA C++ into one publication.
  • 28. • Helix QAC aids in compliance with industry-specific safety and security standards. Helix QAC for Faster Compliance Standard-specific compliance reports. Independently certified. Supports formal rule deviations and compliance auditing.
  • 29. • Helix QAC improves your code quality. Helix QAC for Higher Quality Report code metrics. Remove more defects — earlier in your dev cycle. Prioritize and assign fixes. Report code quality trends.
  • 30. • Helix QAC increases confidence in the safety, security, and reliability of software-based systems. Helix QAC for Accelerated Development High speed analysis across multiple processor cores. Analyze very large codebases (millions of lines of code, thousands of files). Integrate with IDE, VCS, and build tools. Spend less time finding and fixing bugs, more time developing!
  • 31. 31© Perforce Software Inc. All Rights Reserved. Recap 1 Introduction to AUTOSAR Guidelines 2 Key Features & Recent Updates 3 What’s Next? (AUTOSAR & MISRA C++)
  • 33. Contact us to schedule a demo! info@perforce.com
  • 34. Follow us for news and insights! Visit www.perforce.com