Thread overview
[bug] dmc.8.48.9: internal error cgreg 371
May 12, 2006
Nic Tiger
May 15, 2006
Heinz Saathoff
May 15, 2006
Nic Tiger
May 12, 2006
internal error cgreg 371
when compiling following code with
	dmc -o+speed dirTree.cpp
error goes off when
1) no optimization
2) no use of sprintf
3) no use of for

-------- dirTree.cpp -----------
#include <stdio.h>

static inline char *make_path ( const char *base, const char *fname ) {
  static char buf[260];
  _snprintf ( buf, sizeof(buf), "%s/%s", base, fname );
  buf[sizeof(buf)] = '\0';
  return buf;
}

bool walk_dir_tree ( const char *root_dir, int wildcard_num, const char **wildcards ) {
  for ( int i = 0; i < wildcard_num; i ++ )
    make_path ( root_dir, wildcards[i] );
  return true;
}
May 15, 2006
Hello,

Nic Tiger wrote...
> -------- dirTree.cpp -----------
> #include <stdio.h>
> 
> static inline char *make_path ( const char *base, const char *fname ) {
>    static char buf[260];
>    _snprintf ( buf, sizeof(buf), "%s/%s", base, fname );
>    buf[sizeof(buf)] = '\0';
         ^^^^^^^^^^^
Indexing one behind last element. I don't think the compiler will show
internal error because of this, but who knows ;-)

>    return buf;
> }


- Heinz



May 15, 2006
Heinz Saathoff wrote:
> Hello,
> 
> Nic Tiger wrote...
>> -------- dirTree.cpp -----------
>> #include <stdio.h>
>>
>> static inline char *make_path ( const char *base, const char *fname ) {
>>    static char buf[260];
>>    _snprintf ( buf, sizeof(buf), "%s/%s", base, fname );
>>    buf[sizeof(buf)] = '\0';
>          ^^^^^^^^^^^
> Indexing one behind last element. I don't think the compiler will show internal error because of this, but who knows ;-)
> 
>>    return buf;
>> }
>  
> 
> - Heinz
> 
> 
> 
Thanks! Didn't seen it earlier