Skip to content

ForeC compiler does not detect shared use of variable via separate pointers #2

Description

@eyip002

Compiler does not detect that state is shared among multiple threads.

#include <stdio.h>

int state = 0;
int* state_p1 = &state;
int* state_p2 = &state;

// Thread
thread hello(void) {
	*state_p1 = 5;
	printf("%d\n", *state_p1);
}

// Thread
thread world(void) {
	*state_p2 = 10;
	printf("%d\n", *state_p2);
}

// Function main: The entry point of the program.
int main(int argc, char **argv) {
	par(hello, world);
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions