A
Army1987
Given:
#include <stdlib.h>
typedef struct Node {
unsigned char Data[SIZE];
struct Node *Next
} node_t, *list_t;
list_t list;
Does
list = list->Next = malloc(sizeof(node));
cause UB? Is it any different (neglecting style) from
list->Next = malloc(sizeof(node));
list = list->Next;
?
In the former, apparently I only write to l itself once, and only
read l to determine what l->next is. So apparently it is OK to do
that within one sequence point. Am I wrong?
#include <stdlib.h>
typedef struct Node {
unsigned char Data[SIZE];
struct Node *Next
} node_t, *list_t;
list_t list;
Does
list = list->Next = malloc(sizeof(node));
cause UB? Is it any different (neglecting style) from
list->Next = malloc(sizeof(node));
list = list->Next;
?
In the former, apparently I only write to l itself once, and only
read l to determine what l->next is. So apparently it is OK to do
that within one sequence point. Am I wrong?