{"action":"created","issue":{"url":"https://api.github.com/repos/gigablast/open-source-search-engine/issues/69","labels_url":"https://api.github.com/repos/gigablast/open-source-search-engine/issues/69/labels{/name}","comments_url":"https://api.github.com/repos/gigablast/open-source-search-engine/issues/69/comments","events_url":"https://api.github.com/repos/gigablast/open-source-search-engine/issues/69/events","html_url":"https://github.com/gigablast/open-source-search-engine/issues/69","id":119136603,"number":69,"title":"Dependence on GCC Extension that is not Supported by Clang","user":{"login":"martinvahi","id":861080,"avatar_url":"https://avatars.githubusercontent.com/u/861080?v=3","gravatar_id":"","url":"https://api.github.com/users/martinvahi","html_url":"https://github.com/martinvahi","followers_url":"https://api.github.com/users/martinvahi/followers","following_url":"https://api.github.com/users/martinvahi/following{/other_user}","gists_url":"https://api.github.com/users/martinvahi/gists{/gist_id}","starred_url":"https://api.github.com/users/martinvahi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/martinvahi/subscriptions","organizations_url":"https://api.github.com/users/martinvahi/orgs","repos_url":"https://api.github.com/users/martinvahi/repos","events_url":"https://api.github.com/users/martinvahi/events{/privacy}","received_events_url":"https://api.github.com/users/martinvahi/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-11-27T06:08:34Z","updated_at":"2016-01-21T00:20:56Z","closed_at":null,"body":"\r\nAn excerpt from console:\r\n\r\n    XmlDoc.cpp:46419:17: error: variable length array of non-POD element type 'SafeBuf'\r\n            SafeBuf hostBin[g_hostdb.m_numHosts];\r\n                           ^\r\n    XmlDoc.cpp:50874:12: warning: 'this' pointer cannot be null in well-defined C++ code; pointer may be assumed to\r\n          always convert to true [-Wundefined-bool-conversion]\r\n                                                  this, // xd holder (Msg25::m_xd)\r\n                                                  ^~~~\r\n    7 warnings and 1 error generated.\r\n    Makefile:603: recipe for target 'XmlDoc.o' failed\r\n    make: *** [XmlDoc.o] Error \r\n\r\n\r\nA citation from [LLVM home page](http://clang.llvm.org/compatibility.html#vla):\r\n\r\n# Variable-length arrays \r\n\r\nGCC and C99 allow an array's size to be determined at run time. This extension is not permitted in standard C++. However, Clang supports such variable length arrays in very limited circumstances for compatibility with GNU C and C99 programs:\r\n\r\n* The element type of a variable length array must be a POD (\"plain old data\") type, which means that it cannot have any user-declared constructors or destructors, any base classes, or any members of non-POD type. All C types are POD types.\r\n\r\n* Variable length arrays cannot be used as the type of a non-type template parameter.\r\n\r\nIf your code uses variable length arrays in a manner that Clang doesn't support, there are several ways to fix your code:\r\n\r\n- replace the variable length array with a fixed-size array if you can determine a reasonable upper bound at compile time; sometimes this is as simple as changing int size = ...; to const int size = ...; (if the initializer is a compile-time constant);\r\n- use std::vector or some other suitable container type; or\r\n- allocate the array on the heap instead using new Type[] - just remember to delete[] it.\r\n\r\n\r\n\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/gigablast/open-source-search-engine/issues/comments/173410693","html_url":"https://github.com/gigablast/open-source-search-engine/issues/69#issuecomment-173410693","issue_url":"https://api.github.com/repos/gigablast/open-source-search-engine/issues/69","id":173410693,"user":{"login":"Gyscos","id":564903,"avatar_url":"https://avatars.githubusercontent.com/u/564903?v=3","gravatar_id":"","url":"https://api.github.com/users/Gyscos","html_url":"https://github.com/Gyscos","followers_url":"https://api.github.com/users/Gyscos/followers","following_url":"https://api.github.com/users/Gyscos/following{/other_user}","gists_url":"https://api.github.com/users/Gyscos/gists{/gist_id}","starred_url":"https://api.github.com/users/Gyscos/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Gyscos/subscriptions","organizations_url":"https://api.github.com/users/Gyscos/orgs","repos_url":"https://api.github.com/users/Gyscos/repos","events_url":"https://api.github.com/users/Gyscos/events{/privacy}","received_events_url":"https://api.github.com/users/Gyscos/received_events","type":"User","site_admin":false},"created_at":"2016-01-21T00:20:56Z","updated_at":"2016-01-21T00:20:56Z","body":"Index operator in `std::vector` are inlined and not bound-checked anyway - any reason not to use it?\r\nI'd guess the bigger difference is that it would be allocated on the heap, rather than on the stack.\r\nYou'd probably need to benchmark to see if the difference is noticeable."}}