The document discusses sequence points in C and C++ programming. It explains that sequence points govern the order of evaluation and side effects in a program. However, the order of evaluation between sequence points is unspecified, meaning compilers are free to rearrange operations as long as the observable behavior is consistent with the sequence points. This can lead to undefined behavior if a program relies on a specific evaluation order. Several examples are provided to illustrate this.
simple pattern printing programme in c language for beginners.
here you can see code with its pattern programme and easily can understand the programme.
simple pattern printing programme in c language for beginners.
here you can see code with its pattern programme and easily can understand the programme.
1. Perform Linear Search and Binary Search on an array.
Descriptions of the programs:
Read and array of type integer.
Input element from user for searching.
Search the element by passing the array to a function and then returning the position of the element from the function else return -1 if the element is not found.
Display the positions where the element has been found.
2. Implement sparse matrix using array.
Description of program:
Read a 2D array from the user.
Store it in the sparse matrix form, use array of structures.
Print the final array.
3. Create a linked list with nodes having information about a student and perform.
Description of the program:
Insert a new node at specified position.
Delete of a node with the roll number of student specified.
Reversal of that linked list.
4. Create doubly linked list with nodes having information about an employee and perform Insertion at front of doubly linked list and perform deletion at end of that doubly linked list.
5. Create circular linked list having information about a college and perform Insertion at front perform Deletion at end.
6. Create a stack and perform Pop, Push, Traverse operations on the stack using Linear Linked list.
7. Create a Linear Queue using Linked List and implement different operations such as Insert, Delete, and Display the queue elements.
Presented at DevWeek (25th March 2015)
These days, testing is considered a sexy topic for programmers. Who’d have thought it? But what makes for good unit tests (GUTs)? There’s more to effective unit testing than just knowing the assertion syntax of a testing framework.
Testing represents a form of communication and, as such, it offers multiple levels and forms of feedback, not just basic defect detection. Effective unit testing requires an understanding of what forms of feedback and communication are offered by tests, and what styles encourage or discourage such qualities.
What style of test partitioning is most common, and yet scales poorly and is ineffective at properly expressing the behaviour of a class or component? What styles, tricks and tips can be used to make tests more specification-like and can scale as the codebase grows?
This session will address these questions and outline exactly what makes a good unit test.
Everyone talks about raising the bar on the quality of code, but it’s hard to implement when you have no clue where to start. This talk is geared toward all levels of developers, and will teach you how to improve by using the right tools effectively – a must-attend for any PHP developer who wants to scale up their quality.
Michelangelo will tell us about Quality Assurance for PHP in general and show how different QA-related actions can be performed using PhpStorm IDE. The webinar will cover topics including:
Revision control
Syntax checking
Code documentation
Unit Testing with PHPUnit
Measuring code health with a variety of tools
Profiling and debugging with Xdebug
Automation with Phing
Team work and more.
1. Perform Linear Search and Binary Search on an array.
Descriptions of the programs:
Read and array of type integer.
Input element from user for searching.
Search the element by passing the array to a function and then returning the position of the element from the function else return -1 if the element is not found.
Display the positions where the element has been found.
2. Implement sparse matrix using array.
Description of program:
Read a 2D array from the user.
Store it in the sparse matrix form, use array of structures.
Print the final array.
3. Create a linked list with nodes having information about a student and perform.
Description of the program:
Insert a new node at specified position.
Delete of a node with the roll number of student specified.
Reversal of that linked list.
4. Create doubly linked list with nodes having information about an employee and perform Insertion at front of doubly linked list and perform deletion at end of that doubly linked list.
5. Create circular linked list having information about a college and perform Insertion at front perform Deletion at end.
6. Create a stack and perform Pop, Push, Traverse operations on the stack using Linear Linked list.
7. Create a Linear Queue using Linked List and implement different operations such as Insert, Delete, and Display the queue elements.
Presented at DevWeek (25th March 2015)
These days, testing is considered a sexy topic for programmers. Who’d have thought it? But what makes for good unit tests (GUTs)? There’s more to effective unit testing than just knowing the assertion syntax of a testing framework.
Testing represents a form of communication and, as such, it offers multiple levels and forms of feedback, not just basic defect detection. Effective unit testing requires an understanding of what forms of feedback and communication are offered by tests, and what styles encourage or discourage such qualities.
What style of test partitioning is most common, and yet scales poorly and is ineffective at properly expressing the behaviour of a class or component? What styles, tricks and tips can be used to make tests more specification-like and can scale as the codebase grows?
This session will address these questions and outline exactly what makes a good unit test.
Everyone talks about raising the bar on the quality of code, but it’s hard to implement when you have no clue where to start. This talk is geared toward all levels of developers, and will teach you how to improve by using the right tools effectively – a must-attend for any PHP developer who wants to scale up their quality.
Michelangelo will tell us about Quality Assurance for PHP in general and show how different QA-related actions can be performed using PhpStorm IDE. The webinar will cover topics including:
Revision control
Syntax checking
Code documentation
Unit Testing with PHPUnit
Measuring code health with a variety of tools
Profiling and debugging with Xdebug
Automation with Phing
Team work and more.
Lab Manual IV (1).pdf on C++ Programming practiceranaibrahim453
C++ Programming C++ involves writing code to solve problems or create software applications using the C++ programming language. C++ is a powerful and versatile programming language widely used for developing system software, application software, device drivers, embedded software, and much more.Here are some key aspects of C++ programming:
Syntax: C++ syntax is similar to C, but with additional features such as classes, inheritance, polymorphism, templates, and more.
Object-Oriented Programming (OOP): C++ supports OOP, allowing you to organize code into classes and objects, encapsulate data, and implement inheritance, polymorphism, and abstraction.
Standard Template Library (STL): C++ includes a rich set of libraries called the Standard Template Library (STL), which provides containers (like vectors, lists, maps), algorithms (sorting, searching), and other utilities.
Memory Management: C++ gives you control over memory management, allowing you to allocate and deallocate memory using new and delete operators. However, this also means you need to manage memory carefully to avoid memory leaks and other issues.
Performance: C++ is known for its performance and efficiency. It allows low-level manipulation of resources, direct access to hardware, and efficient use of memory.
Platform Independence: C++ code can be compiled to run on different platforms, making it suitable for cross-platform development.
Compile-Time Polymorphism: C++ supports both compile-time polymorphism (achieved through function overloading and templates) and runtime polymorphism (achieved through inheritance and virtual functions).
Exceptions Handling: C++ provides exception handling mechanisms to deal with runtime errors and anomalies gracefully.
IO Streams: C++ offers powerful input/output capabilities through the use of IO streams, which provide a flexible and easy-to-use interface for reading from and writing to files, the console, and other sources.
Multi-threading: C++ has support for multi-threading, allowing you to create concurrent programs for better performance and responsiveness.
When programming in C++, it's essential to pay attention to memory management, avoid undefined behavior, and follow best practices to write efficient and maintainable code. Additionally, understanding the language's features and utilizing them effectively can lead to more robust and elegant solutions. If you have any specific questions or need help with a particular aspect of C++ programming, feel free to ask!Templates: C++ supports templates, allowing you to write generic code that works with any data type. Templates are powerful tools for creating reusable and flexible code.
Lambda Expressions: C++11 introduced lambda expressions, which provide a concise way to define anonymous functions. Lambdas are useful for writing inline functions, especially in algorithms and callback scenarios.
Smart Pointers: C++11 introduced smart pointers (std::unique_ptr, std::shared_ptr, std::weak_ptr), which h
C++ Code as Seen by a Hypercritical ReviewerAndrey Karpov
We all do code reviews. Who doesn't admit this – does it twice as often. C++ code reviewers look like a sapper. .. except that they can make a mistake more than once. But sometimes the consequences are painful . Brave code review world.
Presentation on C++ Programming Languagesatvirsandhu9
It consists information about c++ programming language which is a object oriented language. This presentation is very useful for those who want to learn c++ from beginning.
In this talk I review snippets of test code. The snippets all come from coding dojos performed on http://cyber-dojo.org.
I see the same test anti-patterns time after time after time. Do some of your tests exhibit the same same anti-patterns?
I have run hundreds of test-driven coding dojos using the cyber-dojo app. I see the same test anti-patterns time after time after time. Do some of your tests exhibit the same same anti-patterns?
Explains what a kanban is, and why most kanban boards don't contain any kanbans.
Presented at Lean Kankab UK conference 31st October 2013.
Watch the video here https://www.youtube.com/watch?v=hhHsliAKH84
The Art of the Pitch: WordPress Relationships and SalesLaura Byrne
Clients don’t know what they don’t know. What web solutions are right for them? How does WordPress come into the picture? How do you make sure you understand scope and timeline? What do you do if sometime changes?
All these questions and more will be explored as we talk about matching clients’ needs with what your agency offers without pulling teeth or pulling your hair out. Practical tips, and strategies for successful relationship building that leads to closing the deal.
Essentials of Automations: Optimizing FME Workflows with ParametersSafe Software
Are you looking to streamline your workflows and boost your projects’ efficiency? Do you find yourself searching for ways to add flexibility and control over your FME workflows? If so, you’re in the right place.
Join us for an insightful dive into the world of FME parameters, a critical element in optimizing workflow efficiency. This webinar marks the beginning of our three-part “Essentials of Automation” series. This first webinar is designed to equip you with the knowledge and skills to utilize parameters effectively: enhancing the flexibility, maintainability, and user control of your FME projects.
Here’s what you’ll gain:
- Essentials of FME Parameters: Understand the pivotal role of parameters, including Reader/Writer, Transformer, User, and FME Flow categories. Discover how they are the key to unlocking automation and optimization within your workflows.
- Practical Applications in FME Form: Delve into key user parameter types including choice, connections, and file URLs. Allow users to control how a workflow runs, making your workflows more reusable. Learn to import values and deliver the best user experience for your workflows while enhancing accuracy.
- Optimization Strategies in FME Flow: Explore the creation and strategic deployment of parameters in FME Flow, including the use of deployment and geometry parameters, to maximize workflow efficiency.
- Pro Tips for Success: Gain insights on parameterizing connections and leveraging new features like Conditional Visibility for clarity and simplicity.
We’ll wrap up with a glimpse into future webinars, followed by a Q&A session to address your specific questions surrounding this topic.
Don’t miss this opportunity to elevate your FME expertise and drive your projects to new heights of efficiency.
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...James Anderson
Effective Application Security in Software Delivery lifecycle using Deployment Firewall and DBOM
The modern software delivery process (or the CI/CD process) includes many tools, distributed teams, open-source code, and cloud platforms. Constant focus on speed to release software to market, along with the traditional slow and manual security checks has caused gaps in continuous security as an important piece in the software supply chain. Today organizations feel more susceptible to external and internal cyber threats due to the vast attack surface in their applications supply chain and the lack of end-to-end governance and risk management.
The software team must secure its software delivery process to avoid vulnerability and security breaches. This needs to be achieved with existing tool chains and without extensive rework of the delivery processes. This talk will present strategies and techniques for providing visibility into the true risk of the existing vulnerabilities, preventing the introduction of security issues in the software, resolving vulnerabilities in production environments quickly, and capturing the deployment bill of materials (DBOM).
Speakers:
Bob Boule
Robert Boule is a technology enthusiast with PASSION for technology and making things work along with a knack for helping others understand how things work. He comes with around 20 years of solution engineering experience in application security, software continuous delivery, and SaaS platforms. He is known for his dynamic presentations in CI/CD and application security integrated in software delivery lifecycle.
Gopinath Rebala
Gopinath Rebala is the CTO of OpsMx, where he has overall responsibility for the machine learning and data processing architectures for Secure Software Delivery. Gopi also has a strong connection with our customers, leading design and architecture for strategic implementations. Gopi is a frequent speaker and well-known leader in continuous delivery and integrating security into software delivery.
Epistemic Interaction - tuning interfaces to provide information for AI supportAlan Dix
Paper presented at SYNERGY workshop at AVI 2024, Genoa, Italy. 3rd June 2024
https://alandix.com/academic/papers/synergy2024-epistemic/
As machine learning integrates deeper into human-computer interactions, the concept of epistemic interaction emerges, aiming to refine these interactions to enhance system adaptability. This approach encourages minor, intentional adjustments in user behaviour to enrich the data available for system learning. This paper introduces epistemic interaction within the context of human-system communication, illustrating how deliberate interaction design can improve system understanding and adaptation. Through concrete examples, we demonstrate the potential of epistemic interaction to significantly advance human-computer interaction by leveraging intuitive human communication strategies to inform system design and functionality, offering a novel pathway for enriching user-system engagements.
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Jeffrey Haguewood
Sidekick Solutions uses Bonterra Impact Management (fka Social Solutions Apricot) and automation solutions to integrate data for business workflows.
We believe integration and automation are essential to user experience and the promise of efficient work through technology. Automation is the critical ingredient to realizing that full vision. We develop integration products and services for Bonterra Case Management software to support the deployment of automations for a variety of use cases.
This video focuses on the notifications, alerts, and approval requests using Slack for Bonterra Impact Management. The solutions covered in this webinar can also be deployed for Microsoft Teams.
Interested in deploying notification automations for Bonterra Impact Management? Contact us at sales@sidekicksolutionsllc.com to discuss next steps.
Connector Corner: Automate dynamic content and events by pushing a buttonDianaGray10
Here is something new! In our next Connector Corner webinar, we will demonstrate how you can use a single workflow to:
Create a campaign using Mailchimp with merge tags/fields
Send an interactive Slack channel message (using buttons)
Have the message received by managers and peers along with a test email for review
But there’s more:
In a second workflow supporting the same use case, you’ll see:
Your campaign sent to target colleagues for approval
If the “Approve” button is clicked, a Jira/Zendesk ticket is created for the marketing design team
But—if the “Reject” button is pushed, colleagues will be alerted via Slack message
Join us to learn more about this new, human-in-the-loop capability, brought to you by Integration Service connectors.
And...
Speakers:
Akshay Agnihotri, Product Manager
Charlie Greenberg, Host
JMeter webinar - integration with InfluxDB and GrafanaRTTS
Watch this recorded webinar about real-time monitoring of application performance. See how to integrate Apache JMeter, the open-source leader in performance testing, with InfluxDB, the open-source time-series database, and Grafana, the open-source analytics and visualization application.
In this webinar, we will review the benefits of leveraging InfluxDB and Grafana when executing load tests and demonstrate how these tools are used to visualize performance metrics.
Length: 30 minutes
Session Overview
-------------------------------------------
During this webinar, we will cover the following topics while demonstrating the integrations of JMeter, InfluxDB and Grafana:
- What out-of-the-box solutions are available for real-time monitoring JMeter tests?
- What are the benefits of integrating InfluxDB and Grafana into the load testing stack?
- Which features are provided by Grafana?
- Demonstration of InfluxDB and Grafana using a practice web application
To view the webinar recording, go to:
https://www.rttsweb.com/jmeter-integration-webinar
"Impact of front-end architecture on development cost", Viktor TurskyiFwdays
I have heard many times that architecture is not important for the front-end. Also, many times I have seen how developers implement features on the front-end just following the standard rules for a framework and think that this is enough to successfully launch the project, and then the project fails. How to prevent this and what approach to choose? I have launched dozens of complex projects and during the talk we will analyze which approaches have worked for me and which have not.
DevOps and Testing slides at DASA ConnectKari Kakkonen
My and Rik Marselis slides at 30.5.2024 DASA Connect conference. We discuss about what is testing, then what is agile testing and finally what is Testing in DevOps. Finally we had lovely workshop with the participants trying to find out different ways to think about quality and testing in different parts of the DevOps infinity loop.
2. sequence points
5.1.2.3 Program execution. Clause 2
At certain specified points in the
execution sequence called
sequence points, all side effects of
previous evaluations shall be
complete and no side effects of
subsequent evaluation shall have
taken place.
11. sequence points
Most C and C++ programmers use an implicit
mental model made up of lots of sequence points,
progressing in a mostly left-to-right order.
i + v[++i] + v[++i]
12. sequence points
Most C and C++ programmers use an implicit
mental model made up of lots of sequence points,
progressing in a mostly left-to-right order.
i + v[++i] + v[++i]
13. sequence points
Most C and C++ programmers use an implicit
mental model made up of lots of sequence points,
progressing in a mostly left-to-right order.
i + v[++i] + v[++i]
14. sequence points
Most C and C++ programmers use an implicit
mental model made up of lots of sequence points,
progressing in a mostly left-to-right order.
i + v[++i] + v[++i]
15. sequence points
Most C and C++ programmers use an implicit
mental model made up of lots of sequence points,
progressing in a mostly left-to-right order.
i + v[++i] + v[++i]
16. sequence points
Most C and C++ programmers use an implicit
mental model made up of lots of sequence points,
progressing in a mostly left-to-right order.
i + v[++i] + v[++i]
17. sequence points
Most C and C++ programmers use an implicit
mental model made up of lots of sequence points,
progressing in a mostly left-to-right order.
i + v[++i] + v[++i]
18. sequence points
Most C and C++ programmers use an implicit
mental model made up of lots of sequence points,
progressing in a mostly left-to-right order.
i + v[++i] + v[++i]
19. sequence points
Most C and C++ programmers use an implicit
mental model made up of lots of sequence points,
progressing in a mostly left-to-right order.
i + v[++i] + v[++i]
20. sequence points
Most C and C++ programmers use an implicit
mental model made up of lots of sequence points,
progressing in a mostly left-to-right order.
i + v[++i] + v[++i]
21. sequence points
In reality C and C++ have
very few sequence points
(this is to give maximum
scope for optimization).
22. sequence points where?
• at the end of a full expression
• after the first operand of these operators
&& || ?: ,
• after evaluation of all arguments and
the function call expression in a
function call
30. shall
If a "shall" or a "shall not" requirement
that appears outside of a constraint is
violated, the behavior is undefined.
4. Conformance. Clause 2
undefined behavior:
behavior ... for which this International
Standard imposes no requirements.
3.Terms, definitions, and symbols
31. sequence point: rule-one
Between the previous and next
sequence point an object shall have its
stored value modified at most once by
the evaluation of an expression.
n = n++;
6.5 Expressions. Clause 2.
undefined behavior
32. sequence point: rule-one
Between the previous and next
sequence point an object shall have its
stored value modified at most once by
the evaluation of an expression.
n = n++;
6.5 Expressions. Clause 2.
undefined behavior
33. sequence point: rule-two
Between the previous and next
sequence point the prior value shall be
read only to determine the value to be
stored.
n + n++;
6.5 Expressions. Clause 2.
undefined behavior
34. sequence point: rule-two
Between the previous and next
sequence point the prior value shall be
read only to determine the value to be
stored.
n + n++;
6.5 Expressions. Clause 2.
undefined behavior
35. example
#include <stdio.h>
int main(void)
{
int v[] = { 0,2,4,6,8 };
int i = 1;
int n = i + v[++i] + v[++i];
printf("%dn", n);
}
$ gcc foo.c && ./a.out
gcc
(Mac OS 10.8.2)
http://www.pvv.org/~oma/UnspecifiedAndUndefined_ACCU_Apr2013.pdf
36. example
#include <stdio.h>
int main(void)
{
int v[] = { 0,2,4,6,8 };
int i = 1;
int n = i + v[++i] + v[++i];
printf("%dn", n);
}
$ gcc foo.c && ./a.out
gcc
(Mac OS 10.8.2)
$ gcc foo.c && ./a.out
12
http://www.pvv.org/~oma/UnspecifiedAndUndefined_ACCU_Apr2013.pdf
37. example
#include <stdio.h>
int main(void)
{
int v[] = { 0,2,4,6,8 };
int i = 1;
int n = i + v[++i] + v[++i];
printf("%dn", n);
}
$ gcc foo.c && ./a.out
gcc
$ clang foo.c && ./a.out
clang
(Mac OS 10.8.2)
$ gcc foo.c && ./a.out
12
http://www.pvv.org/~oma/UnspecifiedAndUndefined_ACCU_Apr2013.pdf
38. example
#include <stdio.h>
int main(void)
{
int v[] = { 0,2,4,6,8 };
int i = 1;
int n = i + v[++i] + v[++i];
printf("%dn", n);
}
$ gcc foo.c && ./a.out
gcc
$ clang foo.c && ./a.out
clang
(Mac OS 10.8.2)
$ gcc foo.c && ./a.out
12
$ clang foo.c && ./a.out
11
http://www.pvv.org/~oma/UnspecifiedAndUndefined_ACCU_Apr2013.pdf
39. example
#include <stdio.h>
int main(void)
{
int v[] = { 0,2,4,6,8 };
int i = 1;
int n = i + v[++i] + v[++i];
printf("%dn", n);
}
$ gcc foo.c && ./a.out
gcc
$ clang foo.c && ./a.out
clang
$ icc foo.c && ./a.out
icc
(Mac OS 10.8.2)
$ gcc foo.c && ./a.out
12
$ clang foo.c && ./a.out
11
http://www.pvv.org/~oma/UnspecifiedAndUndefined_ACCU_Apr2013.pdf
40. example
#include <stdio.h>
int main(void)
{
int v[] = { 0,2,4,6,8 };
int i = 1;
int n = i + v[++i] + v[++i];
printf("%dn", n);
}
$ gcc foo.c && ./a.out
gcc
$ clang foo.c && ./a.out
clang
$ icc foo.c && ./a.out
icc
(Mac OS 10.8.2)
$ gcc foo.c && ./a.out
12
$ clang foo.c && ./a.out
11
$ icc foo.c && ./a.out
13
http://www.pvv.org/~oma/UnspecifiedAndUndefined_ACCU_Apr2013.pdf
64. indeterminate value
6.2.4 Storage duration of objects
The initial value of the object is
indeterminate.
J.2 Undefined behavior
The value of an object with
automatic storage duration is
used while it is indeterminate.
65. example
#include <stdio.h>
#include <stdbool.h>
void bar(void)
{
bool b;
if (b)
printf("truen");
if (!b)
printf("falsen");
}
void foo(void);
void bar(void);
int main(void)
{
foo();
bar();
}
void foo(void)
{
char c = 2;
...
}
gcc
Without optimization...
http://www.pvv.org/~oma/UnspecifiedAndUndefined_ACCU_Apr2013.pdf
66. example
#include <stdio.h>
#include <stdbool.h>
void bar(void)
{
bool b;
if (b)
printf("truen");
if (!b)
printf("falsen");
}
void foo(void);
void bar(void);
int main(void)
{
foo();
bar();
}
void foo(void)
{
char c = 2;
...
}
gcc
Without optimization...
true
http://www.pvv.org/~oma/UnspecifiedAndUndefined_ACCU_Apr2013.pdf
67. example
#include <stdio.h>
#include <stdbool.h>
void bar(void)
{
bool b;
if (b)
printf("truen");
if (!b)
printf("falsen");
}
void foo(void);
void bar(void);
int main(void)
{
foo();
bar();
}
void foo(void)
{
char c = 2;
...
}
gcc clang
Without optimization...
true
http://www.pvv.org/~oma/UnspecifiedAndUndefined_ACCU_Apr2013.pdf
68. example
#include <stdio.h>
#include <stdbool.h>
void bar(void)
{
bool b;
if (b)
printf("truen");
if (!b)
printf("falsen");
}
void foo(void);
void bar(void);
int main(void)
{
foo();
bar();
}
void foo(void)
{
char c = 2;
...
}
gcc clang
Without optimization...
true false
http://www.pvv.org/~oma/UnspecifiedAndUndefined_ACCU_Apr2013.pdf
69. example
#include <stdio.h>
#include <stdbool.h>
void bar(void)
{
bool b;
if (b)
printf("truen");
if (!b)
printf("falsen");
}
void foo(void);
void bar(void);
int main(void)
{
foo();
bar();
}
void foo(void)
{
char c = 2;
...
}
gcc clang icc
Without optimization...
true false
http://www.pvv.org/~oma/UnspecifiedAndUndefined_ACCU_Apr2013.pdf
70. example
#include <stdio.h>
#include <stdbool.h>
void bar(void)
{
bool b;
if (b)
printf("truen");
if (!b)
printf("falsen");
}
void foo(void);
void bar(void);
int main(void)
{
foo();
bar();
}
void foo(void)
{
char c = 2;
...
}
gcc clang icc
Without optimization...
true false true
false
http://www.pvv.org/~oma/UnspecifiedAndUndefined_ACCU_Apr2013.pdf
71. example
#include <stdio.h>
#include <stdbool.h>
void bar(void)
{
bool b;
if (b)
printf("truen");
if (!b)
printf("falsen");
}
void foo(void);
void bar(void);
int main(void)
{
foo();
bar();
}
void foo(void)
{
char c = 2;
...
}
gcc clang icc
Without optimization...
With optimization...
true false true
false
http://www.pvv.org/~oma/UnspecifiedAndUndefined_ACCU_Apr2013.pdf
72. example
#include <stdio.h>
#include <stdbool.h>
void bar(void)
{
bool b;
if (b)
printf("truen");
if (!b)
printf("falsen");
}
void foo(void);
void bar(void);
int main(void)
{
foo();
bar();
}
void foo(void)
{
char c = 2;
...
}
gcc clang icc
Without optimization...
With optimization...
true false true
false
false
http://www.pvv.org/~oma/UnspecifiedAndUndefined_ACCU_Apr2013.pdf
73. example
#include <stdio.h>
#include <stdbool.h>
void bar(void)
{
bool b;
if (b)
printf("truen");
if (!b)
printf("falsen");
}
void foo(void);
void bar(void);
int main(void)
{
foo();
bar();
}
void foo(void)
{
char c = 2;
...
}
gcc clang icc
Without optimization...
With optimization...
true false true
false
false
http://www.pvv.org/~oma/UnspecifiedAndUndefined_ACCU_Apr2013.pdf
74. example
#include <stdio.h>
#include <stdbool.h>
void bar(void)
{
bool b;
if (b)
printf("truen");
if (!b)
printf("falsen");
}
void foo(void);
void bar(void);
int main(void)
{
foo();
bar();
}
void foo(void)
{
char c = 2;
...
}
gcc clang icc
Without optimization...
With optimization...
true false true
false
false false
http://www.pvv.org/~oma/UnspecifiedAndUndefined_ACCU_Apr2013.pdf
75. example
#include <stdio.h>
#include <stdbool.h>
void bar(void)
{
bool b;
if (b)
printf("truen");
if (!b)
printf("falsen");
}
void foo(void);
void bar(void);
int main(void)
{
foo();
bar();
}
void foo(void)
{
char c = 2;
...
}
gcc clang icc
Without optimization...
With optimization...
true false true
false
false false
http://www.pvv.org/~oma/UnspecifiedAndUndefined_ACCU_Apr2013.pdf
76. example
#include <stdio.h>
#include <stdbool.h>
void bar(void)
{
bool b;
if (b)
printf("truen");
if (!b)
printf("falsen");
}
void foo(void);
void bar(void);
int main(void)
{
foo();
bar();
}
void foo(void)
{
char c = 2;
...
}
gcc clang icc
Without optimization...
With optimization...
true false true
false
false false false
http://www.pvv.org/~oma/UnspecifiedAndUndefined_ACCU_Apr2013.pdf
121. Debugging is twice as hard as
writing the code in the first
place. Therefore, if you write
the code as cleverly as possible,
you are, by definition, not smart
enough to debug it.
125. virtual destructor
class random_dice_roller
: public
dice_roller
{
public:
...
};
answer:
any code can delete a derived object
through a base class pointers*
void contrived_example()
{
dice_roller * ptr =
new random_dice_roller();
...
delete ptr;
}
* and it will work!
126. virtual destructor
class random_dice_roller
: public
dice_roller
{
public:
...
};
answer:
any code can delete a derived object
through a base class pointers*
void contrived_example()
{
dice_roller * ptr =
new random_dice_roller();
...
delete ptr;
}
* and it will work!
127. virtual destructor?
class random_dice_roller
: public
dice_roller
{
public:
...
};
question:
should any code be able to write
delete expressions?
void contrived_example()
{
dice_roller * ptr =
new random_dice_roller();
...
delete ptr;
}
class dice_roller
{
public:
virtual ~dice_roller();
...
};
128. virtual destructor
suppose you don't want arbitrary code to
be able to write delete expressions?
void contrived_example()
{
dice_roller * ptr =
new random_dice_roller();
...
delete ptr;
}
class dice_roller
{
public:
...
protected:
~dice_roller();
};
150. you must not tell lies!
#ifndef FUBAR_INCLUDED
#define FUBAR_INCLUDED
#include "wibble.hpp"
class snafu;
class widget;
class fubar
{
...
};
#endif
namespace fishing
{
class snafu
{
...
};
}
fubar.hpp
fishing/snafu.hpp
namespace fishing
{
class widget
{
...
};
}
fishing/widget.hpp
151. you must not tell lies!
#ifndef FUBAR_INCLUDED
#define FUBAR_INCLUDED
#include "wibble.hpp"
namespace fishing
{
class snafu;
class widget;
}
class fubar
{
...
};
#endif
fubar.hpp
namespace fishing
{
class snafu
{
...
};
}
fishing/snafu.hpp
namespace fishing
{
class widget
{
...
};
}
fishing/widget.hpp
152. you must not tell lies!
#ifndef FUBAR_INCLUDED
#define FUBAR_INCLUDED
#include "wibble.hpp"
namespace std
{
class string;
}
class fubar
{
...
};
#endif
namespace std
{
class string
{
...
};
}
fubar.hpp <string>
it's not like this!
153. you must not tell lies!
#ifndef FUBAR_INCLUDED
#define FUBAR_INCLUDED
#include "wibble.hpp"
namespace std
{
class string;
}
class fubar
{
...
};
#endif
namespace std
{
template<typename T>
class basic_string
{
...
};
typedef basic_string<char> string;
...
}
fubar.hpp <string>
it's a bit like this!
154. you must not tell lies!
#ifndef FUBAR_INCLUDED
#define FUBAR_INCLUDED
#include "wibble.hpp"
namespace std
{
template<typename T>
class basic_string;
typdef
basic_string<char>
string;
}
class fubar
{
...
};
#endif
namespace std
{
template<typename T>
class basic_string
{
...
};
typedef basic_string<char> string;
...
}
fubar.hpp <string>
?
?
155. you must not tell lies!
#ifndef FUBAR_INCLUDED
#define FUBAR_INCLUDED
#include "wibble.hpp"
namespace std
{
template<typename T>
class basic_string;
typdef
basic_string<char>
string;
}
class fubar
{
...
};
#endif
namespace std
{
template<typename T1,
typename T2 = ...,
typename T3 = ...>
class basic_string
{
...
};
typedef basic_string<char> string;
...
}
fubar.hpp <string>
default template types
169. include your own header 1st
#ifndef FUBAR_INCLUDED
#define FUBAR_INCLUDED
#include "wibble.hpp"
#include <vector>
class fubar
{
public:
...
void fu();
...
private:
std::vector<wibble> wibbles;
};
#endif
#include "fubar.hpp"
...
void fubar::fu()
{
...
}
fubar.hpp fubar.cpp
170. better still - make sure each
header compiles (on its own) as
part of the build!
#ifndef FUBAR_INCLUDED
#define FUBAR_INCLUDED
#include "wibble.hpp"
#include <vector>
class fubar
{
public:
...
void fu();
...
private:
std::vector<wibble> wibbles;
};
#endif
fubar.hpp