[EXT_EP-8870] Use of stdarg.h va_start macro causes a write to the wrong local variable Created: 03/Apr/18  Updated: 19/Feb/20  Resolved: 03/Apr/18

Status: Fixed
Project: Embedded Software & Tools
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Medium
Reporter: TI User Assignee: TI User
Resolution: Fixed Votes: 0
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Product: Code Generation Tools
Internal ID: CODEGEN-4634
Forum URL: https://e2e.ti.com/support/development_tools/compiler/f/343/t/677249
Found In Release: C6000_8.2.0
 C6000_8.1.0B1
 C2000_16.9.0.LTS
Fix In Release: C6000_8.1.8
 C2000_16.9.9.LTS
 ARM_16.9.9.LTS
Workaround: The test case for codegen-4634 has both a va_list declaration and a use of va_start. If the two are placed together, by moving the va_list declaration into the scope with the va_start, the problem does not occur.

The general workaround is to ensure an expression appears before the first nested scope. Exactly how to do that will depend on the situation.
Release Notes: A function with a nested scope that declares local variables and appears before any expressions in the function, and also declares top-level locals after that, may mishandle the local variables in a way that acts as though some share a location though they're supposed to be distinct. I.e.,

  int test(int arg, ...)
  {
    { int a = 0; }
    int b;

may mishandle a, b, arg, or any extra arguments.

Known cases all involve the ellipsis (...) parameter, but it is not known if that is also a necessary prerequisite.

 Description   

Use of stdarg.h va_start macro causes a write to the wrong local variable


Generated at Sat Dec 13 11:37:47 CST 2025 using Jira 10.3.7#10030007-sha1:a563685562f94d165eb4e158cfb2a142338d8c54.