{"action":"created","issue":{"url":"https://api.github.com/repos/TrustInSoft/tis-interpreter/issues/62","repository_url":"https://api.github.com/repos/TrustInSoft/tis-interpreter","labels_url":"https://api.github.com/repos/TrustInSoft/tis-interpreter/issues/62/labels{/name}","comments_url":"https://api.github.com/repos/TrustInSoft/tis-interpreter/issues/62/comments","events_url":"https://api.github.com/repos/TrustInSoft/tis-interpreter/issues/62/events","html_url":"https://github.com/TrustInSoft/tis-interpreter/issues/62","id":150585235,"number":62,"title":"No warnings: comparisons with addresses of const-qualified compound literals","user":{"login":"ch3root","id":10299648,"avatar_url":"https://avatars.githubusercontent.com/u/10299648?v=3","gravatar_id":"","url":"https://api.github.com/users/ch3root","html_url":"https://github.com/ch3root","followers_url":"https://api.github.com/users/ch3root/followers","following_url":"https://api.github.com/users/ch3root/following{/other_user}","gists_url":"https://api.github.com/users/ch3root/gists{/gist_id}","starred_url":"https://api.github.com/users/ch3root/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ch3root/subscriptions","organizations_url":"https://api.github.com/users/ch3root/orgs","repos_url":"https://api.github.com/users/ch3root/repos","events_url":"https://api.github.com/users/ch3root/events{/privacy}","received_events_url":"https://api.github.com/users/ch3root/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-04-23T19:02:02Z","updated_at":"2016-05-26T14:42:36Z","closed_at":null,"body":"Source code:\r\n```c\r\nint main()\r\n{\r\n  \"abc\" == (const char[]){\"abc\"};\r\n  (const char[]){\"abc\"} + 2 == (const char[]){\"bc\\0d\"} + 1;\r\n  // (const int[]){1, 2, 3} + 1 == &(const int){2}; // fails on this expr due to #33\r\n}\r\n```\r\n\r\ntis-interpreter (cb9990430757902189787926452a0be6f910dbb2) output:\r\n```\r\n[value] Analyzing a complete application starting at main\r\n[value] Computing initial state\r\n[value] Initial state computed\r\n[value] done for function main\r\n```\r\n\r\n6.5.2.5p7: \"String literals, and compound literals with const-qualified types, need not designate distinct objects.101)\"\r\nFootnote: \"101) This allows implementations to share storage for string literals and constant compound literals with the same or overlapping representations.\"\r\n\r\nP.S. I'm impressed how accurate tis-interpreter warns about comparisons of string literals.\r\n*"},"comment":{"url":"https://api.github.com/repos/TrustInSoft/tis-interpreter/issues/comments/221891380","html_url":"https://github.com/TrustInSoft/tis-interpreter/issues/62#issuecomment-221891380","issue_url":"https://api.github.com/repos/TrustInSoft/tis-interpreter/issues/62","id":221891380,"user":{"login":"ch3root","id":10299648,"avatar_url":"https://avatars.githubusercontent.com/u/10299648?v=3","gravatar_id":"","url":"https://api.github.com/users/ch3root","html_url":"https://github.com/ch3root","followers_url":"https://api.github.com/users/ch3root/followers","following_url":"https://api.github.com/users/ch3root/following{/other_user}","gists_url":"https://api.github.com/users/ch3root/gists{/gist_id}","starred_url":"https://api.github.com/users/ch3root/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ch3root/subscriptions","organizations_url":"https://api.github.com/users/ch3root/orgs","repos_url":"https://api.github.com/users/ch3root/repos","events_url":"https://api.github.com/users/ch3root/events{/privacy}","received_events_url":"https://api.github.com/users/ch3root/received_events","type":"User","site_admin":false},"created_at":"2016-05-26T14:42:36Z","updated_at":"2016-05-26T14:42:36Z","body":"Const local variables (at least, arrays and structs, with recursion) are a problem too. In practice, with clang.\r\n\r\nclang bug -- https://llvm.org/bugs/show_bug.cgi?id=18538 (not mine).\r\n\r\nSomewhat related links:\r\nhttp://open-std.org/jtc1/sc22/wg14/www/docs/dr_078.html\r\nhttp://open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#734\r\n\r\nSource code:\r\n```c\r\n#include <stdio.h>\r\n\r\nint main()\r\n{\r\n  static const void *p = 0, *q = 0;\r\n  const int x[1] = {0};\r\n  const struct { int i; } y = {0};\r\n\r\n  if (!p) {\r\n    p = &x;\r\n    q = &y;\r\n    main();\r\n  } else {\r\n    printf(\"%d %d\\n\", p == &x, q == &y);\r\n  }\r\n}\r\n```\r\n\r\ntis-interpreter (21064e80e9b5d6d2fba71c6ed30e5906355d8eb2) output:\r\n```\r\n[value] Analyzing a complete application starting at main\r\n[value] Computing initial state\r\n[value] Initial state computed\r\n\r\n0 0\r\n\r\n[value] done for function main\r\n```\r\n\r\ngcc (GCC) 7.0.0 20160523 (experimental) w/ubsan output:\r\n```\r\n$ gcc -std=c11 -pedantic -Wall -Wextra -O3 -fsanitize=undefined test.c && ./a.out\r\n0 0\r\n```\r\n\r\nclang version 3.9.0 (trunk 270444) w/ubsan output:\r\n```\r\n$ clang -std=c11 -Weverything -Wno-vla -O3 -fsanitize=undefined test.c && ./a.out\r\n1 1\r\n```\r\n"}}
{"actor":{"display_login":"ch3root"}}