[llvm-bugs] [Bug 44273] New: Why is there a difference between void and int ?

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Dec 11 05:50:26 PST 2019


https://bugs.llvm.org/show_bug.cgi?id=44273

            Bug ID: 44273
           Summary: Why is there a difference between void and int ?
           Product: clang
           Version: 9.0
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: C
          Assignee: unassignedclangbugs at nondot.org
          Reporter: 1059252359 at qq.com
                CC: blitzrakete at gmail.com, dgregor at apple.com,
                    erik.pilkington at gmail.com, llvm-bugs at lists.llvm.org,
                    richard-llvm at metafoo.co.uk

Hi, when define a pointer NISLParameter0 without assigning it a value, Clang
will behave inconsistently depending on the return value of the main function.
When main function’s return type is “void”, clang will not allocate an address
for it. But if main function’s return type is “int”, clang will allocate an
address successfully.Although void main is not recommended by ISO C standard,
they should also be consistent.

TestCase:
#include<stdio.h>
#include<string.h>
void function(void *d)
{
    if (d == NULL)
        printf("%d\n",111);
}
int main()
{
    int *NISLParameter0;
    function(NISLParameter0);
    return 0;
}


Command:
./clang/version9.0/bin/clang testcase.c


Output:
111 (main function’s return type is void)
    (no output when main function’s return type is int)

Expected output:
The same between void and int return types. 

Is this right for clang? Looking forward to your reply.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20191211/a66b2c22/attachment.html>


More information about the llvm-bugs mailing list