Bug 16447 – make illegal for functions containing a `naked` asm block to return `auto`
Status
RESOLVED
Resolution
INVALID
Severity
enhancement
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2016-08-31T08:14:56Z
Last change time
2022-11-10T13:33:50Z
Assigned to
No Owner
Creator
Basile-z
Comments
Comment #0 by b2.temp — 2016-08-31T08:14:56Z
When an auto function contains no return statement a warning could be emitted.
example:
auto foo(int x)
{
asm
{
naked;
add RAX, 1;
ret;
}
}
The return type here is "void". Other case can exist, even w/o iasm, where the coder can get strange and inaccurate error message if he's forget his return statement(s).
- When an auto function, depending on the static if conditions, returns void or something then no warning, b/c to return the something a return statement is present.
- When an auto function returns void and contains no return statement, warn.
Comment #1 by b2.temp — 2016-08-31T12:02:18Z
(In reply to b2.temp from comment #0)
> The return type here is "void"
forgot the end of the sentence: "instead of int, which the coder has forgot to specify".
Comment #2 by b2.temp — 2016-08-31T12:28:30Z
nvm, i've made it in dscanner.
Comment #3 by cauterite — 2016-08-31T18:28:51Z
(In reply to b2.temp from comment #2)
> nvm, i've made it in dscanner.
Nevermind? Huh?
This sounds like a valid concern to me. There is no way your inline-assembly example should be allowed to compile with auto return type.
Comment #4 by razvan.nitu1305 — 2022-11-10T13:33:50Z
Why not? Assembly usage is for expert programmers so the compiler assumes that you know what you are doing. A third party tool check (like dscanner) is the way forward here.