[PATCH] D12169: Relax constexpr rules to improve __builtin_object_size's accuracy

Steven Wu via cfe-commits cfe-commits at lists.llvm.org
Fri Sep 4 22:42:19 PDT 2015


steven_wu added a subscriber: steven_wu.
steven_wu added a comment.

This commit seems to cause miscompile in LNT testsuite with -O0 and -O3
http://lab.llvm.org:8080/green/job/perf_o0g_run/7070/warnings2Result/new/
http://lab.llvm.org:8080/green/job/perf_o3lto_run/15591/warnings2Result/new/

Looks like there is an undefined in LNT testsuite, here is the relevant code for consumer-lame:

  typedef struct                                                                  
  {                                                                               
    int used;                                                                     
    int valid;                                                                    
    char title[31];                                                               
    char artist[31];                                                              
    char album[31];                                                               
    char year[5];                                                                 
    char comment[31];                                                             
    char tagtext[128];                                                            
    char genre[1];                                                                
    unsigned char track;                                                          
                                                                                  
  }   ID3TAGDATA; 
  void id3_inittag(ID3TAGDATA *tag) {                                             
    ...
    strcpy( tag->genre, "ΓΏ"); /* unset genre */      
    ...                             
  }

Here is the suggested change:

  diff --git a/MultiSource/Benchmarks/MiBench/consumer-lame/id3tag.c b/MultiSource/Benchmarks/MiBench/consumer-lame/id3tag.c
  index e24a966..23f2b86 100644
  --- a/MultiSource/Benchmarks/MiBench/consumer-lame/id3tag.c
  +++ b/MultiSource/Benchmarks/MiBench/consumer-lame/id3tag.c
  @@ -34,7 +34,7 @@ void id3_inittag(ID3TAGDATA *tag) {
          strcpy( tag->album, "");
          strcpy( tag->year, "");    
          strcpy( tag->comment, "");
  -       strcpy( tag->genre, "<FF>");    /* unset genre */
  +       tag->genre[0] = '<FF>'; /* unset genre */
          tag->track = 0;
   
          tag->valid = 0;         /* not ready for writing*/

However, I have trouble understand the code in consumer-typeset. It crashes in z07.c:138
By the looks of it, the code is trying to copy the include path (specified on command line), which is setup to be "$PATH_TO_TEST_SUITE/MultiSource/Benchmarks/MiBench/consumer-typeset/data/include" into unsigned char ostring[4]. From the look of the code, it is trying to utilize all the size in OBJECT to store the entire string. I don't know if that is fixable. Let me know if you have any better idea of how to fix that.


http://reviews.llvm.org/D12169





More information about the cfe-commits mailing list