Stack Overflow confusion

const Tmp{T <: AbstractFloat} = SMatrix{3,4,T,12}

Why does this overflow?

Tmp(rand(Float32,3,4))

of course, this works,

Tmp{Float32}(rand(Float32,3,4))

but I don’t understand why the first case overflows.

It doesn’t, for me:

julia> versioninfo()
Julia Version 1.8.2
Commit 36034abf26 (2022-09-29 15:21 UTC)
Platform Info:
  OS: Windows (x86_64-w64-mingw32)
  CPU: 8 × Intel(R) Core(TM) i7-4770 CPU @ 3.40GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-13.0.1 (ORCJIT, haswell)
  Threads: 4 on 8 virtual cores

(@v1.8) pkg> st StaticArrays
Status `C:\Users\oheil\.julia\environments\v1.8\Project.toml`
  [90137ffa] StaticArrays v1.5.9

julia> using StaticArrays

julia> const Tmp{T <: AbstractFloat} = SMatrix{3,4,T,12}
SMatrix{3, 4, T, 12} where T<:AbstractFloat (alias for SArray{Tuple{3, 4}, T, 2, 12} where T<:AbstractFloat)

julia> Tmp(rand(Float32,3,4))
3×4 SMatrix{3, 4, Float32, 12} with indices SOneTo(3)×SOneTo(4):
 0.824309  0.662805  0.774721  0.721328
 0.870767  0.584382  0.798654  0.76885
 0.24125   0.181562  0.136964  0.974316

I’m not sure what’s going on. It only happens when I load a module that I am developing. So this is not a bug with StaticArrays.

I can just try what you provide.

In general, the line

Tmp(rand(Float32,3,4))

is equivalent to

julia> a=rand(Float32,3,4)
julia> Tmp(a)
julia> @which Tmp(a)
(::Type{SA})(a::AbstractArray) where SA<:StaticArray in StaticArrays at C:\Users\oheil\.julia\packages\StaticArrays\PUoe1\src\convert.jl:169

Perhaps you have defined some convert method for your Type-alias which has a bug?

Without your complete code it’s difficult to say. Perhaps you can find some MWE (minimal working example) which let us reproduce the stack overflow.