This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Warning about __DATE__ and __TIME__


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]