<div dir="ltr">Dear Clang Devs,<br><br>Consider the following code snippet:<br><br>#include <sched.h><br>void whatever() {<br>  cpu_set_t d, s1, s2;<br>  CPU_AND(&d, &s1, &s2);<br>}<br><br>On compiling normally, I see no warnings being emitted: <br>$ clang++ -c test.cpp -o test.o -Wall -Wextra -Wunused-value -Werror <br>$ <br><br>However, if I ask Clang to save the temporary files:<br>$ clang++ -c test.cpp -o test.o -Wall -Wextra -Wunused-value -Werror --save-temps<br>test.cpp:5:308: error: expression result unused [-Werror,-Wunused-value]<br>  (__extension__ ({ cpu_set_t *__dest = (&d); __const __cpu_mask *__arr1 = (&s1)->__bits; __const __cpu_mask *__arr2 = (&s2)->__bits; size_t __imax = (sizeof (cpu_set_t)) / sizeof (__cpu_mask); size_t __i; for (__i = 0; __i < __imax; ++__i) ((__cpu_mask *) __dest->__bits)[__i] = __arr1[__i] & __arr2[__i]; __dest; }));<br>                                                                                                                                                                                                                                                                                                                   ^~~~~~<br>1 error generated.<br><div><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><br>Another way to look at this problem is by first storing the intermediate output and then trying to use it:<br>$ clang++ -E -c test.cpp -o test.ii -Wall -Wextra -Wunused-value -Werror <br>$ clang++ -c test.ii -o test.o -Wall -Wextra -Wunused-value -Werror <br>test.cpp:5:308: error: expression result unused [-Werror,-Wunused-value]<br>  (__extension__ ({ cpu_set_t *__dest = (&d); __const __cpu_mask *__arr1 = (&s1)->__bits; __const __cpu_mask *__arr2 = (&s2)->__bits; size_t __imax = (sizeof (cpu_set_t)) / sizeof (__cpu_mask); size_t __i; for (__i = 0; __i < __imax; ++__i) ((__cpu_mask *) __dest->__bits)[__i] = __arr1[__i] & __arr2[__i]; __dest; }));<br>                                                                                                                                                                                                                                                                                                                   ^~~~~~<br>1 error generated.<br><br><br>Questions:<br>- Is this report of unused value legit? GCC doesn't warn anything on the same snippet.<br>- Is this behavior expected? Why does the warning throw up only when the end user wants to do anything with the intermediate outputs? I ended up here because this was failing my project when I was trying to use distcc.</div><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><br><br><br>Cheers!<br><br>Nehal J Wani</div></div></div>