a strange segment fault about ltp-posix test

Hi all

In the ltp-posix test,there is a case in open_posix_testsuite\conformance\interfaces\timer_gettime\speculative/6-1.c

I run the above code,it will has a segment fault, if I modify it to below,it works well

Anybody can tell me why?

Reducing the problem to its essence makes it easier to understand

#include <time.h>
#define BOGUSTID 9999

timer_t tid;
  
#if WANT_SEG_FAULT
   tid = (timer_t) BOGUSTID
#else
   int tval=BOGUSTID;
   tid = (timer_t) &tval;
#endif

The correct header is being included but an assumption is being made that tid is capable of storing a value as shown above. Generally this assumption is wrong as timer_t is specified to be an opaque type in POSIX.1. On most versions of GNU/Linux, timer_t is actually defined by

#define timer_t   void *

In your example you are trying to stuff 9999 into a void * - which is not on.

BTW, your workaround is defective also. tid is not being set to 9999 but to the address of tval.