source: translator/examples/swap.c @ 6c3744e

ADTaaron-thesisarm-ehast-experimentalcleanup-dtorsctordeferred_resndemanglerenumforall-pointer-decaygc_noraiijacob/cs343-translationjenkins-sandboxmemorynew-astnew-ast-unique-exprnew-envno_listpersistent-indexerpthread-emulationqualifiedEnumresolv-newstringwith_gc
Last change on this file since 6c3744e was 0b8cd722, checked in by Peter A. Buhr <pabuhr@…>, 10 years ago

fix uninitialized value, fix memory reads after frees

  • Property mode set to 100644
File size: 375 bytes
RevLine 
[42dcae7]1extern "C" {
2    int printf( const char *, ... );
3}
4
5forall( type T )
[0b8cd722]6void swap( T *left, T *right ) {
[17cd4eb]7    T temp;
8    temp = *left;
9    *left = *right;
10    *right = temp;
[42dcae7]11}
12
13int main() {
14    int x = 1, y = 2;
[17cd4eb]15    printf( "%d %d\n", x, y );
[0b8cd722]16    swap( &x, &y );
17    printf( "%d %d\n", x, y );
[42dcae7]18}
19
20// Local Variables: //
21// compile-command: "../../bin/cfa swap.c" //
22// End: //
Note: See TracBrowser for help on using the repository browser.