Bug 64354 - no preprocessor symbol __SANITIZE_THREAD__
Summary: no preprocessor symbol __SANITIZE_THREAD__
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: sanitizer (show other bugs)
Version: 4.9.2
: P3 normal
Target Milestone: 5.0
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-12-18 17:41 UTC by Robert Henry
Modified: 2016-10-16 16:31 UTC (History)
7 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Robert Henry 2014-12-18 17:41:33 UTC
compiling
 gcc -fsanitize=thread
does not pre-define preprocessor symbol __SANITIZE_THREAD__ (bad)

however, compiling
 gcc -fsanitize=address
does pre-define preprocessor symbol __SANITIZE_ADDRESS__ (good)

The situations should be symmetric.  I would suggest adding __SANITIZE_THREAD__ rather than deleting __SANITIZE_ADDRESS__.
Comment 1 Dmitry Vyukov 2016-04-12 07:14:59 UTC
We've hit this issue while implementing Go support for C++ ThreadSanitizer:
https://github.com/golang/go/issues/14602
__has_feature obviously does not work. Providing __SANITIZE_THREAD__ looks very reasonable since we provide __SANITIZE_ADDRESS__.
Comment 2 chefmax 2016-05-19 12:06:31 UTC
Author: chefmax
Date: Thu May 19 12:05:59 2016
New Revision: 236457

URL: https://gcc.gnu.org/viewcvs?rev=236457&root=gcc&view=rev
Log:
2016-05-19  Maxim Ostapenko  <m.ostapenko@samsung.com>

	PR sanitizer/64354
	* cppbuiltin.c (define_builtin_macros_for_compilation_flags): Add new
	builtin __SANITIZE_THREAD__ macros for fsanitize=thread switch.
	* doc/cpp.texi: Document new macros.

	* c-c++-common/tsan/sanitize-thread-macro.c: New test.

Added:
    trunk/gcc/testsuite/c-c++-common/tsan/sanitize-thread-macro.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/cppbuiltin.c
    trunk/gcc/doc/cpp.texi
    trunk/gcc/testsuite/ChangeLog
Comment 3 Dmitry Vyukov 2016-05-19 12:10:35 UTC
Thanks!
Comment 4 Andrew Pinski 2016-10-16 16:31:55 UTC
Fixed.