Two identical systems but clang gives warning on only one

I don't think average C programmer cares much about safety, standards, undefined behavior and so on.
Well, it doesn't matter what an average C programmer cares about :). Here's it's about the proper way of doing things.

Though I do think warning comes from the issue I mentioned earlier it is still interesting to see why OP doesn't have this issue on one of his machines. But then again, full uname, clang -v, file output of the binary and even larger piece of code would clarify more things.
 
It's a multi-threaded implementation of FastCGI that someone gave me long ago to play with. I was told it worked, and it does, but it was just a "let's see what this does" sort of thing. So now that I have a proof of concept I can build on that.

But my misunderstanding was never about the code.
 
Here's it's about the proper way of doing things.

It's quite idiomatic, though. Since the point of contention seems to be the potential inability to fit an integer into a pointer, you can likely throw a few assertions into your program (preferably static assert from C11):
Code:
static_assert(sizeof(int) <= sizeof(void*), "Oh crap");
 
_martin - you advise to pass the address of a stack variable as the context variable to a pthread function. That is creates a nasty hard-to-diagnose bug. Apologies to drhowarddrfine for going off topic.
 
But my misunderstanding was never about the code.
I'm curious to see why you have the warning on one system and not the other. For that it would help to see what I've mentioned. I still think the warning is stemming from casting int to void* (size of 4 to size of 8). If you passed the variable as (void*)(intptr_t)i that warning gets silenced. Maybe default behavior of each clang is different?

To compare -v of my clang shows only:

Code:
$ clang -v
FreeBSD clang version 6.0.1 (tags/RELEASE_601/final 335540) (based on LLVM 6.0.1)
Target: x86_64-unknown-freebsd12.0
Thread model: posix
InstalledDir: /usr/bin
$

unitrunker raised valid point why one passes value as argument even though it's defined as void*.
 
I'm curious to see why you have the warning on one system and not the other.
Me, too. That's why I started this thread and asked that question. But I answered all your questions throughout this thread.

Unless something comes up, I'm going to reinstall llvm but, again, I couldn't at one time because I needed gcc for something and I couldn't fit gcc and llvm on the small disk of the VPS. I have a feeling having gnu ld as the linker is the reason for no warning.
 
I don't think this is related to ld, warning is coming from compiler itself. You could do clang -c test.c to avoid linking. I bet you'll still see the warning.

How exactly are you compiling it ? Any chance that cc points to gcc on one of the servers ?
 
Back
Top