[cfe-dev] proposal to add new warning -Wdate-time

Prathamesh Kulkarni bilbotheelffriend at gmail.com
Tue Apr 22 05:41:09 PDT 2014


Hi,
    I was wondering if it's a good idea to add a new warning -Wdate-time,
that warns on use of __DATE__ and __TIME__ macros ?
I have attached patch for the same.

The rationale behind the warning is that these macros might prevent
reproducible builds from the same source.
This warning has been recently added to gcc:
http://gcc.gnu.org/ml/gcc/2013-11/msg00066.html

Here's a sample test-case:
#include <stdio.h>

int main()
{
  printf ("%s\n", __TIME__);
  printf ("%s\n", __DATE__);
  return 0;
}

date-time.c:5:19: warning: macro __TIME__ might prevent reproducible
builds [-Wdate-time]
  printf ("%s\n", __TIME__);
                       ^
date-time.c:6:19: warning: macro __DATE__ might prevent reproducible
builds [-Wdate-time]
  printf ("%s\n", __DATE__);
                       ^
2 warnings generated.


Thanks and Regards,
Prathamesh
-------------- next part --------------
A non-text attachment was scrubbed...
Name: date-time.patch
Type: text/x-patch
Size: 2372 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20140422/bf656650/attachment.bin>


More information about the cfe-dev mailing list