# define __strcmp_gc(s1, s2, l2) \
(__extension__ ({ __const unsigned char *__s1 = \
(__const unsigned char *) (__const char *) (s1); \
register int __result = \
__s1[0] - ((__const unsigned char *) \
(__const char *) (s2))[0]; \
if (l2 > 0 && __result == 0) \
{ \
__result = (__s1[1] \
- ((__const unsigned char *) \
(__const char *) (s2))[1]); \
if (l2 > 1 && __result == 0) \
{ \
__result = \
(__s1[2] - ((__const unsigned char *) \
(__const char *) (s2))[2]); \
if (l2 > 2 && __result == 0) \
__result = \
(__s1[3] \
- ((__const unsigned char *) \
(__const char *) (s2))[3]); \
} \
} \
__result; }))
o __strcmp_gc(s1, "-v", 2), clang warns that s2[3] in the code may be out-of-bounds.To view this discussion on the web visit https://groups.google.com/d/msgid/ats-lang-users/CAFLa5WM_MeCr-eP_-j-_Urd3B0pTrvuCPXLv7grWfAiMahKSjg%40mail.gmail.com.
On Thu, Dec 18, 2014 at 5:30 PM, Hongwei Xi <gmh...@gmail.com> wrote:
> Clang must evaluate strlen("-v") to get 2. But what would be a good criterion to
> determine whether strlen("-v") should or should not be evaluated at compile-time?
I've always assumed what could be evaluated at compile-time should be
evaluated at compile-time. no?
> I am using clang 3.0.
Well that's not fair. What's preventing you from upgrading to at least 3.4?
WARNING: While resolving call to function 'v1aldec_tr_102' arguments were dropped!
WARNING: While resolving call to function 'f_71' arguments were dropped!
WARNING: While resolving call to function 'f_41' arguments were dropped!
WARNING: While resolving call to function '_2home_2hwxi_2research_2Postiats_2git_2src_2pats_trans2_2esats__d1ecl_tr' arguments were dropped!
WARNING: While resolving call to function 'f_4' arguments were dropped!
WARNING: While resolving call to function 's1rtdef_tr_20' arguments were dropped!
WARNING: While resolving call to function 's1tacst_tr_22' arguments were dropped!
WARNING: While resolving call to function '__ats_fun_33' arguments were dropped!
WARNING: While resolving call to function 'f2_35' arguments were dropped!
WARNING: While resolving call to function 'f1_34' arguments were dropped!
WARNING: While resolving call to function 'm1acarg_tr_91' arguments were dropped!
WARNING: While resolving call to function 'f_93' arguments were dropped!
WARNING: While resolving call to function 'f_92' arguments were dropped!
WARNING: While resolving call to function 'trans2_env_add_m2acarg_88' arguments were dropped!
WARNING: While resolving call to function '__ats_fun_104' arguments were dropped!
WARNING: While resolving call to function 'v1ardec_tr_108' arguments were dropped!
WARNING: While resolving call to function 'f_110' arguments were dropped!
WARNING: While resolving call to function 'prv1ardec_tr_114' arguments were dropped!
WARNING: While resolving call to function 'f_116' arguments were dropped!
WARNING: While resolving call to function '_2home_2hwxi_2research_2Postiats_2git_2src_2pats_trans2_2esats__d1ecl_tr' arguments were dropped!
WARNING: While resolving call to function 'f_93' arguments were dropped!
WARNING: While resolving call to function 'f_92' arguments were dropped!
WARNING: While resolving call to function 'f1_34' arguments were dropped!