Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

initializing struct member with function returning type alias gives c error with -prod (msvc): C2440: 'initializing': cannot convert from 'f32 *' to 'f32' #22392

Closed
daansystems opened this issue Oct 2, 2024 · 0 comments · Fixed by #22399

Comments

@daansystems
Copy link

daansystems commented Oct 2, 2024

V doctor:

V full version: V 0.4.8 18eee34.c01186c
OS: windows, Microsoft Windows 11 Pro v22631 64-bit
Processor: 24 cpus, 64bit, little endian, 

getwd: D:\vbug2
vexe: C:\v\v.exe
vexe mtime: 2024-10-02 18:15:48

vroot: OK, value: C:\v
VMODULES: OK, value: C:\Users\info\.vmodules
VTMP: OK, value: C:\Users\info\AppData\Local\Temp\v_0

Git version: git version 2.42.0.windows.2
Git vroot status: 0.4.8-25-gc01186c7-dirty
.git/config present: true

CC version: Error: 'cc' is not recognized as an internal or external command,

operable program or batch file.


thirdparty/tcc status: thirdparty-windows-amd64 b425ac82

What did you do?
./v -g -o vdbg cmd/v && ./vdbg main.v

module main

type Mat4 = [16]f32

pub fn mat4(x0 f32, x1 f32, x2 f32, x3 f32, x4 f32, x5 f32, x6 f32, x7 f32, x8 f32, x9 f32, x10 f32, x11 f32, x12 f32, x13 f32, x14 f32, x15 f32) Mat4 {
	return [
		x0,
		x1,
		x2,
		x3,
		x4,
		x5,
		x6,
		x7,
		x8,
		x9,
		x10,
		x11,
		x12,
		x13,
		x14,
		x15,
	]!
}

pub fn unit_m4() Mat4 {
	return mat4(f32(1), 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)
}

struct GameObject  {
mut:
	transform Mat4 = unit_m4()
}

fn main() {
	p := GameObject{}
	println(p)
}

What did you expect to see?

no c error

What did you see instead?

v -prod .
Microsoft (R) C/C++ Optimizing Compiler Version 19.41.34120 for x64
Copyright (C) Microsoft Corporation.  All rights reserved.

cl -w /we4013 /volatile:ms /F 16777216 /O2 /MD /DNDEBUG "C:\Users\info\AppData\Local\Temp\v_0\vbug2.01J977SWEJ927TVDRT16WNTE8S.tmp.c" -I "C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\ucrt" -I "C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.41.34120\include" -I "C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um" -I "C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\shared" /DGC_NOT_DLL=1 /DGC_WIN32_THREADS=1 /DGC_THREADS=1 -I "C:\v\thirdparty\libatomic_ops" -I "C:\v\thirdparty\libgc\include" "C:\v/thirdparty/libatomic_ops/atomic_ops.obj" "C:\v/thirdparty/libgc/gc.obj" ucrtd.lib kernel32.lib user32.lib advapi32.lib ws2_32.lib dbghelp.lib user32.lib /link /NOLOGO /OUT:"D:\vbug2\vbug2.exe" /LIBPATH:"C:\Program Files (x86)\Windows Kits\10\Lib\10.0.22621.0\ucrt\X64" /LIBPATH:"C:\Program Files (x86)\Windows Kits\10\Lib\10.0.22621.0\um\X64" /LIBPATH:"C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.41.34120\lib\X64" /DEBUG:FULL /INCREMENTAL:NO /OPT:REF /OPT:ICF

vbug2.01J977SWEJ927TVDRT16WNTE8S.tmp.c
C:\Users\info\AppData\Local\Temp\v_0\vbug2.01J977SWEJ927TVDRT16WNTE8S.tmp.c(13597): error C2440: 'initializing': cannot convert from 'f32 *' to 'f32'

builder error: msvc error

Note

You can use the 👍 reaction to increase the issue's priority for developers.

Please note that only the 👍 reaction to the issue itself counts as a vote.
Other reactions and those to comments will not be taken into account.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant