ahatanak added inline comments.

================
Comment at: clang/tools/driver/driver.cpp:251
+                     std::string &OptFile) {
+  T OptVal = ::getenv(EnvOptSet);
+  if (OptVal) {
----------------
SeanP wrote:
> This change is not POSIX compliant.  If T is char *, the next call to 
> getenv() on line 253 invalidates the value saved into OptVal.  getenv() is 
> allowed to use the same buffer for the return value.  That means the value 
> OptVal is pointing at will be overwritten by the next call.
> 
> When T is bool you need the `!!` operators to get the char * converted to 
> bool correctly.
> 
> I suggest leaving this function as it was and calling getenv() directly for 
> the scenario involving CC_PRINT_HEADERS_FORMAT.  Make sure you save the 
> getenv() results into std::string so the value isn't overridden.
Thank you for notifying me of the bug. It should be fixed in 
https://github.com/llvm/llvm-project/commit/34aa2e24c89ae39c0db4254d8aafcae0285dbe34


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D137996/new/

https://reviews.llvm.org/D137996

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to