Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conflicting rewrites for extern sized arrays #733

Open
kyleheadley opened this issue Oct 21, 2021 · 2 comments
Open

Conflicting rewrites for extern sized arrays #733

kyleheadley opened this issue Oct 21, 2021 · 2 comments
Labels
array bounds benchmark failure A bug causing a failure in our nightly benchmark tests incomplete description rewriter

Comments

@kyleheadley
Copy link
Member

This happens in Lua:

lapi.c:35:12: error: redefinition of 'lua_ident' with a different type: 'const char _Checked[]' vs '_Array_ptr<const char>'
const char lua_ident _Checked[] =
           ^
./lua.h:147:31: note: previous declaration is here
extern _Array_ptr<const char> lua_ident : count(129);
                              ^

and in ZLib:

../trees.h:73:11: error (redefinition): redefinition of '_dist_code' with a different type: 'const uch _Checked[512]' vs '_Array_ptr<const uch>' (aka '_Array_ptr<const unsigned char>')
const uch _dist_code _Checked[DIST_CODE_LEN] = {
          ^
../deflate.h:321:32: note: previous declaration is here
  extern _Array_ptr<const uch> _dist_code : count(512);
                               ^

The compiler does not complain for simple examples, like when 3C converts one line in each file.

@kyleheadley kyleheadley added rewriter array bounds benchmark failure A bug causing a failure in our nightly benchmark tests incomplete description labels Oct 21, 2021
@kyleheadley
Copy link
Member Author

kyleheadley commented Oct 21, 2021

also in libtiff(macro-expanded -alltypes):

libtiff/tif_fax3sm.c:5:22: error: redefinition of 'TIFFFaxMainTable' with a different type: 'const TIFFFaxTabEnt _Checked[128]' vs '_Array_ptr<const TIFFFaxTabEnt>'
 const TIFFFaxTabEnt TIFFFaxMainTable _Checked[128] = {
                     ^
libtiff/tif_fax3.h:90:40: note: previous declaration is here
extern _Array_ptr<const TIFFFaxTabEnt> TIFFFaxMainTable : count(128);
                                       ^

@john-h-kastner
Copy link
Collaborator

Here's a simple test case:

extern const char lua_ident[];
const char lua_ident[] = "foo";

converts to

extern _Array_ptr<const char> lua_ident : count(4);
const char lua_ident _Checked[] = "foo";

Note that the error does not occur if the definition comes before the declaration.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
array bounds benchmark failure A bug causing a failure in our nightly benchmark tests incomplete description rewriter
Projects
None yet
Development

No branches or pull requests

2 participants