Skip to content

-fno-builtin wont works if -O0 #142780

Closed as not planned
Closed as not planned
@Duiccni

Description

@Duiccni

The code I tried to compile is given in the bottom used clang version 20.1.5 Target: x86_64-pc-windows-msvc
without -O flag it gives error:

test-0bfdf5.o : error LNK2019: unresolved external symbol memset referenced in function _entry
CCC\test.exe : fatal error LNK1120: 1 unresolved externals
clang: error: linker command failed with exit code 1120 (use -v to see invocation)

which i believe it shoudnt becouse of -fno-builtin flag i used
with -O flag it works just fine


#undef UNICODE

#include <Windows.h>

HWND hwnd;
HINSTANCE hInstance;
char* className = "MyWindowClass";

LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
   if (uMsg == WM_CLOSE) {
      return -1;
   }
   return DefWindowProc(hwnd, uMsg, wParam, lParam);
}

void _entry() {
   hInstance = GetModuleHandle(NULL);

   WNDCLASS wc = {0};
   wc.lpfnWndProc = WindowProc;
   wc.hInstance = hInstance;
   wc.lpszClassName = className;
   RegisterClassA(&wc);
   hwnd = CreateWindowExA(0, className, "My Window", WS_VISIBLE | WS_SYSMENU | WS_CAPTION, 0, 0, 320, 320, NULL, NULL, hInstance, NULL);

   MSG msg;
loop:
   while (PeekMessageA(&msg, hwnd /*NULL*/, 0, 0, PM_REMOVE)) {
      DWORD r = DispatchMessageA(&msg);
      if (r == -1) {
         MessageBoxA(NULL, "WM_CLOSE", "Info", 0); // I expect it not to be work because hwnd set to hwnd not null
         goto end;
      }
   }

   Sleep(500);
   goto loop;
end:

   DestroyWindow(hwnd);
   UnregisterClassA(className, hInstance);

   ExitProcess(0);
}```

Metadata

Metadata

Assignees

No one assigned

    Labels

    clang:frontendLanguage frontend issues, e.g. anything involving "Sema"invalidResolved as invalid, i.e. not a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions