WeSearch

Consequences of passing too few register parameters to a C function

Raymond Chen· ·4 min read · 0 reactions · 0 comments · 8 views
#programming#c#itanium#memory#undefined behavior#Itanium#C#C++
Consequences of passing too few register parameters to a C function
⚡ TL;DR · AI summary

The article discusses the implications of passing too few parameters to a C function. It highlights that such actions can lead to undefined behavior, including potential memory corruption. Special cases, such as those involving Itanium architecture, are also examined for their unique handling of uninitialized registers.

Key facts
Original article
The Old New Thing · Raymond Chen
Read full at The Old New Thing →
Opening excerpt (first ~120 words) tap to expand

In our exploration of calling conventions for various processors on Windows, we learned that in many cases, some of the parameters are passed in registers. Suppose that there is a function that takes two parameters, but you know that the function ignores the second parameter if the first parameter is positive. What happens if you call the function with just one parameter (say, passing zero). The function should ignore the second parameter, so why does it matter that you didn’t pass one? Even though the function doesn’t use the parameter, it still may decide to use the storage for that parameter as a conveniently provided scratch space.

Excerpt limited to ~120 words for fair-use compliance. The full article is at The Old New Thing.

Anonymous · no account needed
Share 𝕏 Facebook Reddit LinkedIn Threads WhatsApp Bluesky Mastodon Email

Discussion

0 comments

More from The Old New Thing