I wonder if you can reuse Ident() from tests/asan_test_utils.h instead of using volatile. <div>Like this: </div><div>  char *mem = Ident(malloc(10));</div><div><br></div><div><div>// This function returns its parameter but in such a way that compiler                                                                                                                              </div>
<div>// can not prove it.                                                                                                                                                                                </div><div>template<class T>                                                                                                                                                                                   </div>
<div>__attribute__((noinline))                                                                                                                                                                           </div><div>static T Ident(T t) {                     </div>
</div><div>...</div><div><br></div><div><br></div><div>--kcc </div><div><br><br><div class="gmail_quote">On Mon, Dec 5, 2011 at 12:44 AM, Alexander Potapenko <span dir="ltr"><<a href="mailto:glider@google.com">glider@google.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">Fix GCD tests for AddressSanitizer on Mac.<br>
The following patch declares the char* vars holding the memory<br>
allocations as volatile, which prevents the compiler from optimizing<br>
them and breaking the tests.<br>
I'm also enabling the tests by default, as the GCD support in ASan<br>
runtime library is quite stable already.<br>
<span class="HOEnZb"><font color="#888888"><br>
--<br>
Alexander Potapenko<br>
Software Engineer<br>
Google Moscow<br>
</font></span></blockquote></div><br></div>