jagomart
digital resources
picture1_Programming Pdf 184291 | 00 Rust Introduct


 182x       Filetype PDF       File size 0.36 MB       Source: www.cs.umd.edu


File: Programming Pdf 184291 | 00 Rust Introduct
cmsc 330 organization of programming languages type safe low level programming with rust cmsc 330 spring 2021 copyright 2018 19 michael hicks the university copyright 2018 19 michael hicks the ...

icon picture PDF Filetype PDF | Posted on 01 Feb 2023 | 2 years ago
Partial capture of text on file.
        CMSC 330: Organization of Programming 
                           Languages
              Type-Safe, Low-level Programming with 
                               Rust
                            CMSC 330 Spring 2021
                                    Copyright © 2018-19 Michael Hicks, the University 
                                     Copyright © 2018-19 Michael Hicks, the University 
                                    of Maryland. Some material based on 
                                      Copyright © 2018-19 Michael Hicks, the University 
                                     of Maryland. Some material based on 
                                    https://doc.rust-lang.org/book/second-edition/index.
                                       Copyright © 2018-19 Michael Hicks, the University 
                                      of Maryland. Some material based on 
                                     https://doc.rust-lang.org/book/second-edition/index.
                                    html
                                       of Maryland. Some material based on 
                                      https://doc.rust-lang.org/book/second-edition/index.
                                     html
                                       https://doc.rust-lang.org/book/second-edition/index.
                                      html
                                       html
      Type Safety in Programming Languages
      • In a type-safe language, the type system enforces well 
        defined behavior. Formally, a language is type-safe iff
                          G ⊢ e : t and G ⊢ A implies 
                A; e ⇒ v and ⊢ v : t or that e runs forever
      • A; e ⇒ v says e evaluates v under environment A
      • G ⊢ e : t says e has type t under type environment G
                     
      • G ⊢ A says A is compatible with G
         –  For all x, A(x) = v  implies G(x) = t and ⊢ v : t 
      CMSC 330 -  Spring 2021
     C/C++: Not Type-Safe – Spatially Unsafe
                      G ⊢ e : t and G ⊢ A implies 
             A; e ⇒ v and ⊢ v : t or that e runs forever
     Type safety is violated by buffer overflows
        int main() {
          int x = 1, *p = &x;
          int y = 0, *q = &y;
          *(q+1) = 5; // overwrites p
          return *p; // crash 
        }
     CMSC 330 -  Spring 2021
     C/C++: Not Type-Safe – Temporally Unsafe 
     and dangling pointers (uses of pointers to freed memory)
           { int *x = ...malloc();
             free(x);
             *x = 5; /* oops! */
           }
     … which can happen via the stack, too:
           int *foo(void) { int z = 5; return &z; }
           void bar(void) {
             int *x = foo();
             *x = 5; /* oops! */
           }
     CMSC 330 -  Spring 2021
The words contained in this file might help you see if this file matches what you are looking for:

...Cmsc organization of programming languages type safe low level with rust spring copyright michael hicks the university maryland some material based on https doc lang org book second edition index html safety in a language system enforces well defined behavior formally is iff g e t and implies v or that runs forever says evaluates under environment has compatible for all x c not spatially unsafe violated by buffer overflows int main p y q overwrites return crash temporally dangling pointers uses to freed memory malloc free oops which can happen via stack too foo void z bar...

no reviews yet
Please Login to review.