Lab 8
10/16 @ 11:59 PM
Not accepted late
The Lab Assignment

This lab exists helps to give you some familiarity with the concept of undefined behavior. To complete the lab assignment, you should create a directory with several C++ programs that demonstrate certain features, as well as a makefile that shows how they can be diagnosed. Submit a tarball of that directory to Canvas.

Part 1

Create a program that uses a divide-by-zero behavior that would be caught at runtime by the ubsan module. Add two Makefile targets, one that forces the behavior to be reported at runtime, and one that allows the behavior to go unchecked

Part 2

Create a program that uses an out-ofbounds behavior that would be caught at runtime by the memsan or asan module. Add two Makefile targets for the same program, one that forces the behavior to be reported at runtime, and one that allows the behavior to go unchecked.

Part 3

Create a program that uses a behavior that could be statically detected and cause an error in the compiler. Add two Makefile targets, one that rejects the program (i.e. will not compile it) and one that will compile the program without complaint.

Submission Instructions

Create a tarball consisting of a single directory with all of your work in it, such as code or written answers. If you have any auxiliary files (READMEs, Makefiles, etc.), be sure to include those as well. Name your work directory l8 and name the tarball l8.tgz. Upload your tarball to the L8 Canvas assignment.

Labs will be graded under one of following criteria:

  1. Effort: You will automatically be given full credit for the labwork if the GTA determines that your participation in the lab was meaningful - i.e. you attended the lab session and used the time to make a good-faith attempt to complete the work. It is the sole discretion of the GTA to determine if you put in sufficient effort. Even if you expect an effort-based grade, you should turn in your (possibly incomplete) work.
  2. Correctness: If you do not participant meaningfully in lab (i.e. you do not attend the lab session), your grade will be assessed based on the correctness of your lab submission.

Advice: How to Approach Labs

The two-criteria grading scheme above is designed to avoid wasting your time. You should not feel obligated to attend the lab, and in fact should only do so if you want help from the GTA on the labwork assignment or whatever project is currently in progress. Here's a handy flowchart for how I suggest you approach lab: