This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Warning about __DATE__ and __TIME__
- From: Jonathan Wakely <jwakely dot gcc at gmail dot com>
- To: Ian Lance Taylor <iant at google dot com>
- Cc: Gerald Pfeifer <gerald at pfeifer dot com>, GCC Development <gcc at gcc dot gnu dot org>
- Date: Mon, 4 Nov 2013 21:04:04 +0000
- Subject: Re: Warning about __DATE__ and __TIME__
- Authentication-results: sourceware.org; auth=none
- References: <alpine dot LNX dot 2 dot 00 dot 1310271959580 dot 1528 at trevally dot site> <CAKOQZ8wy8Ekkbb5yKzj7VzpKFu+Zhw3idv9uiOavBknOC7_5xA at mail dot gmail dot com>
On 28 October 2013 21:13, Ian Lance Taylor wrote:
> On Sun, Oct 27, 2013 at 12:04 PM, Gerald Pfeifer <gerald@pfeifer.com> wrote:
>> To make it easier to reproduce builds of software and entire GNU/Linux
>> distributions, RMS had the idea of adding a warning to GCC that warns
>> about the use of __DATE__ and __TIME__.
>>
>> Short of "interesting" changes to the environment or #defining these
>> two, as soon as a program uses __DATE__ or __TIME__ at least once,
>> builds of the program will differ for that reason alone. (There are
>> others, but one step at a time; this is not the point of this mail).
>>
>> I was thinking a new warning -Wdate-time or similar could address
>> this.
>
> I don't have any strong objection, but I'll note that it's even easier
> to use -D options.
>
> CC='gcc -D__DATE__=today'
It's undefined behaviour in both C and C++ to redefine pre-defined
macros such as __DATE__ or __TIME__.
The undefined behaviour study group of the C++ committee are
considering making it ill-formed, which would require a diagnostic.