SlideShare a Scribd company logo
An Empirical Study of Goto in C
Code from GitHub Repositories
Mei Nagappan, Romain Robbes, Yasutaka Kamei, Éric
Tanter, Shane McIntosh, Audris Mockus, Ahmed E. Hassan
Go-to statement
considered
harmful (1968)
A Case against the
GO TO Statement
(1968)
Do Practitioners care?
Do Practitioners care?
https://xkcd.com/292/
Do Practitioners care?
Do Practitioners care?
Do Practitioners care?
Impact of Article on Research Community
Impact of Article on Research Community
Impact of Article on Research Community
Impact of Article
Koenig: Dijkstra provides strong logical evidence for why
goto statements can introduce problems in software.
Well informed and often well argued
opinions
Shift from opinion to facts
Our Goal: Empirically Examine the use of
goto
Shift from opinion to facts
Example
Label
Goto Statement
PRELIMINARY ANALYSIS
Do developers use goto
statements in their source code?
Experiment
11,627
Projects
Goto Miner
11,627
Projects
Goto Miner
3,093
Projects
Despite the popularity of Dijkstra’s
case against goto

11,627
Projects
Goto Miner
3,093
Projects
246,657 out of the 2,150,387 files
(11.47%)
Extent of use of goto statements by
Developers is non-trivial
Two Research Questions
Two Research Questions
RQ1: What are goto statements used
for?
Two Research Questions
RQ1: What are goto statements used
for?
RQ2: Do developers remove/modify
goto statements?
Qualitative Analysis
246,669
C files
384
files
Properties
and
Purposes
of Goto
Iterative
Tagging
Sample
Selection
Basic Bean Counting
Num of Goto Statements
per Function
Num of Goto Labels
per Function
Not many goto statements per function
Num of Goto Statements
per Function
Num of Goto Labels
per Function
Not many goto statements per function
Very few lines of code in label blocks
Median = 4 LOC
Properties
Context
Why did Dijkstra think goto statements
would have ‘disastrous effects’?
‘The go to statement as it stands is just
too primitive; it is too much an invitation
to make a mess of one’s program.’
Desire to make programs verifiable
Desire to make programs verifiable
3 ways to reach the code under the label
“back”
First way: Top down execution
Second way: condition2 == true
Third way: done == false
Difficult to know what has been
executed so far.
Hence go to statements must be
avoided!
Our Findings
Multiple goto jumps to the same label
This is what Dijkstra feared about!
62%
Single point of entry into label block!
9%
But not all use of goto is like what
Dijkstra feared!
Stacking labels at the bottom of
functions is prevalent
27%
Spaghetti code is uncommon
6%
Most of the jumps are forward, not
backwards
90%
14%
Purposes
Most goto usage is for error handling
and cleanup
Error Handling =
80%
Cleanup = 40%
Most goto usage is for error handling
and cleanup
Error Handling =
80%
Goto and labels used to emulate a try/catch or
finally mechanism
Cleanup = 40%
Less intuitive usages such as control-
exit and loop-create are less common
10%
Less intuitive usages such as control-
exit and loop-create are less common
9%
Most usages of goto statements appear to
be for error handling and cleanup
Quantitative Analysis
Mine
Commits
6 OSS
Projects
Quantitative Analysis
Mine
Commits
6 OSS
Projects
Link to
Bugs
180 Days
Of Commit
History
Quantitative Analysis
Mine
Commits
6 OSS
Projects
Link to
Bugs
180 Days
Of Commit
History
Bug Fix
Commits
Extract
Goto
Almost no Gotos are removed/modified
in the post-release phase of a project
0
2
4
6
8
10
12
14
16
Removed
Modified
Even fewer Gotos are
removed/modified in the post-release
bug fixes
0
1
2
3
4
5
6
Removed
Modified
Even fewer Gotos are
removed/modified in the post-release
bug fixes
0
1
2
3
4
5
6
Removed
Modified
Developers did not remove/modify goto
statements in the post-release phase.
Summary
An Empirical Study of Goto in C Code from GitHub Repositories
An Empirical Study of Goto in C Code from GitHub Repositories
An Empirical Study of Goto in C Code from GitHub Repositories
An Empirical Study of Goto in C Code from GitHub Repositories

More Related Content

PDF
Presentation
PDF
Conversion Hotel 2018 Keynote: Lizzie Eardley
PDF
Works For Me! Characterizing Non-Reproducible Bug Reports
PDF
Pairwise Software Test Design - What exactly is pairwise coverage? What is 3-...
PPT
Setting up your first open gl program
PPTX
Take Action on your Passion
PPTX
Automatic Load Test Verification Using Control Charts
PPTX
Icsm2010 kamei
Presentation
Conversion Hotel 2018 Keynote: Lizzie Eardley
Works For Me! Characterizing Non-Reproducible Bug Reports
Pairwise Software Test Design - What exactly is pairwise coverage? What is 3-...
Setting up your first open gl program
Take Action on your Passion
Automatic Load Test Verification Using Control Charts
Icsm2010 kamei

Viewers also liked (20)

PPTX
A Study of the Quality-Impacting Practices of Modern Code Review at Sony Mobile
PDF
Defect Prediction: Accomplishments and Future Challenges
PDF
The impact of supercomputers on MSR
PPT
Revisiting the Applicability of the Pareto Principle to Core Development Team...
PDF
Eclipse Day India 2015 - Keynote - Stephan Herrmann
PDF
Get Ready for Agile Methods: How to manage constant and rapid change in IT pr...
PDF
Get Functional on the CLR: Intro to Functional Programming with F#
PDF
Icse2011 build maintenance
PPTX
No silver bullet essence and accidents of software engineering
PPTX
No silver bullet
PDF
An Automated Approach for Recommending When to Stop Performance Tests
PPTX
C# Async on iOS and Android - Miguel de Icaza, CTO of Xamarin
PDF
A Holistic Approach to Evolving Software Systems
PPT
Mining Unstructured Software Repositories Using IR Models
PDF
Mineograph Mining Automation Software
PPTX
ëč…데읎터와 ê”ìœĄë°ìŽí„°ë§ˆìŽë‹ (êł ë €ëŒ€í•™ê” 대학원 강의) 6ìŁŒì°š
PPTX
Mining the Modern Code Review Repositories: A Dataset of People, Process and ...
PDF
Data mining software comparison
PDF
Swift and Kotlin Presentation
PPTX
임태현, software catastrophe
A Study of the Quality-Impacting Practices of Modern Code Review at Sony Mobile
Defect Prediction: Accomplishments and Future Challenges
The impact of supercomputers on MSR
Revisiting the Applicability of the Pareto Principle to Core Development Team...
Eclipse Day India 2015 - Keynote - Stephan Herrmann
Get Ready for Agile Methods: How to manage constant and rapid change in IT pr...
Get Functional on the CLR: Intro to Functional Programming with F#
Icse2011 build maintenance
No silver bullet essence and accidents of software engineering
No silver bullet
An Automated Approach for Recommending When to Stop Performance Tests
C# Async on iOS and Android - Miguel de Icaza, CTO of Xamarin
A Holistic Approach to Evolving Software Systems
Mining Unstructured Software Repositories Using IR Models
Mineograph Mining Automation Software
ëč…데읎터와 ê”ìœĄë°ìŽí„°ë§ˆìŽë‹ (êł ë €ëŒ€í•™ê” 대학원 강의) 6ìŁŒì°š
Mining the Modern Code Review Repositories: A Dataset of People, Process and ...
Data mining software comparison
Swift and Kotlin Presentation
임태현, software catastrophe
Ad

More from SAIL_QU (20)

PDF
Studying the Integration Practices and the Evolution of Ad Libraries in the G...
PDF
Studying the Dialogue Between Users and Developers of Free Apps in the Google...
PPTX
Improving the testing efficiency of selenium-based load tests
PDF
Studying User-Developer Interactions Through the Distribution and Reviewing M...
PDF
Studying online distribution platforms for games through the mining of data f...
PPTX
Understanding the Factors for Fast Answers in Technical Q&A Websites: An Empi...
PDF
Investigating the Challenges in Selenium Usage and Improving the Testing Effi...
PDF
Mining Development Knowledge to Understand and Support Software Logging Pract...
PPTX
Which Log Level Should Developers Choose For a New Logging Statement?
PPTX
Towards Just-in-Time Suggestions for Log Changes
PDF
The Impact of Task Granularity on Co-evolution Analyses
PPTX
A Framework for Evaluating the Results of the SZZ Approach for Identifying Bu...
PPTX
How are Discussions Associated with Bug Reworking? An Empirical Study on Open...
PPTX
A Study of the Relation of Mobile Device Attributes with the User-Perceived Q...
PDF
A Large-Scale Study of the Impact of Feature Selection Techniques on Defect C...
PPTX
Studying the Dialogue Between Users and Developers of Free Apps in the Google...
PDF
What Do Programmers Know about Software Energy Consumption?
PPTX
Threshold for Size and Complexity Metrics: A Case Study from the Perspective ...
PDF
Revisiting the Experimental Design Choices for Approaches for the Automated R...
PPTX
Measuring Program Comprehension: A Large-Scale Field Study with Professionals
Studying the Integration Practices and the Evolution of Ad Libraries in the G...
Studying the Dialogue Between Users and Developers of Free Apps in the Google...
Improving the testing efficiency of selenium-based load tests
Studying User-Developer Interactions Through the Distribution and Reviewing M...
Studying online distribution platforms for games through the mining of data f...
Understanding the Factors for Fast Answers in Technical Q&A Websites: An Empi...
Investigating the Challenges in Selenium Usage and Improving the Testing Effi...
Mining Development Knowledge to Understand and Support Software Logging Pract...
Which Log Level Should Developers Choose For a New Logging Statement?
Towards Just-in-Time Suggestions for Log Changes
The Impact of Task Granularity on Co-evolution Analyses
A Framework for Evaluating the Results of the SZZ Approach for Identifying Bu...
How are Discussions Associated with Bug Reworking? An Empirical Study on Open...
A Study of the Relation of Mobile Device Attributes with the User-Perceived Q...
A Large-Scale Study of the Impact of Feature Selection Techniques on Defect C...
Studying the Dialogue Between Users and Developers of Free Apps in the Google...
What Do Programmers Know about Software Energy Consumption?
Threshold for Size and Complexity Metrics: A Case Study from the Perspective ...
Revisiting the Experimental Design Choices for Approaches for the Automated R...
Measuring Program Comprehension: A Large-Scale Field Study with Professionals
Ad

Recently uploaded (20)

PDF
System and Network Administration Chapter 2
PDF
Wondershare Filmora 15 Crack With Activation Key [2025
PDF
Understanding Forklifts - TECH EHS Solution
PDF
PTS Company Brochure 2025 (1).pdf.......
PDF
Audit Checklist Design Aligning with ISO, IATF, and Industry Standards — Omne...
PPTX
Reimagine Home Health with the Power of Agentic AI​
PDF
Navsoft: AI-Powered Business Solutions & Custom Software Development
PDF
2025 Textile ERP Trends: SAP, Odoo & Oracle
PPTX
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
PDF
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
PDF
AI in Product Development-omnex systems
PDF
Softaken Excel to vCard Converter Software.pdf
PDF
How Creative Agencies Leverage Project Management Software.pdf
PDF
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
PDF
Design an Analysis of Algorithms I-SECS-1021-03
PPTX
Transform Your Business with a Software ERP System
PPTX
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
 
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
PDF
Nekopoi APK 2025 free lastest update
PDF
Design an Analysis of Algorithms II-SECS-1021-03
System and Network Administration Chapter 2
Wondershare Filmora 15 Crack With Activation Key [2025
Understanding Forklifts - TECH EHS Solution
PTS Company Brochure 2025 (1).pdf.......
Audit Checklist Design Aligning with ISO, IATF, and Industry Standards — Omne...
Reimagine Home Health with the Power of Agentic AI​
Navsoft: AI-Powered Business Solutions & Custom Software Development
2025 Textile ERP Trends: SAP, Odoo & Oracle
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
AI in Product Development-omnex systems
Softaken Excel to vCard Converter Software.pdf
How Creative Agencies Leverage Project Management Software.pdf
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
Design an Analysis of Algorithms I-SECS-1021-03
Transform Your Business with a Software ERP System
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
 
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
Nekopoi APK 2025 free lastest update
Design an Analysis of Algorithms II-SECS-1021-03

An Empirical Study of Goto in C Code from GitHub Repositories

Editor's Notes

  • #24: Motivation: Some goto usage may be part of relatively harmless patterns, while others may be much more nefarious.
  • #25: Motivation: Did goto related code have bugs in them?