source: tests/poly-many-arsz.cfa @ 62b5940

Last change on this file since 62b5940 was 641707d, checked in by Andrew Beach <ajbeach@…>, 2 months ago

More fixing of warnings. Including another error that slipped through to the build and the rest of the 'easy' fixes on tests not in a directory.

  • Property mode set to 100644
File size: 1.4 KB
Line 
1//
2// Cforall Version 1.0.0 Copyright (C) 2023 University of Waterloo
3//
4// The contents of this file are covered under the licence agreement in the
5// file "LICENCE" distributed with Cforall.
6//
7// poly-many-arsz.cfa -- using many built-in array types with concrete sizes
8//
9// Author           : Mike Brooks
10// Created On       : Tue Aug 13 12:00:00 2024
11// Last Modified By :
12// Last Modified On :
13// Update Count     :
14//
15
16// This behaviour was once broken, as trac #175.
17
18forall( T1*, T2* )
19struct mypair {
20    T1 first;
21    T2 second;
22};
23
24void baseline( void ) {
25    printf("baseline\n");
26
27    // no declaration of x
28    // facts that are true of y:
29
30    mypair(char[2], char) y @= {};
31    printf("|y| = %zd\n", sizeof(y));    // 3
32
33    y.second = 0;
34    printf("y.second = %d\n", y.second); // 0
35
36    y.first[1] = 17;
37    printf("y.second = %d\n", y.second); // 0
38}
39
40void withInterference( void ) {
41    printf("with interference\n");
42
43    // adding this declaration of x ...
44    mypair(char[1], char) x @= {};
45    printf("|x| = %zd\n", sizeof(x));    // 2
46
47    // ... even if it isn't really used ...
48    (void)x;
49
50    // ... must not affect the observed facts of y:
51
52    mypair(char[2], char) y @= {};
53    printf("|y| = %zd\n", sizeof(y));    // 3
54
55    y.second = 0;
56    printf("y.second = %d\n", y.second); // 0
57
58    y.first[1] = 17;
59    printf("y.second = %d\n", y.second); // 0
60}
61
62int main() {
63    baseline();
64    withInterference();
65    return 0;
66}
Note: See TracBrowser for help on using the repository browser.