Location in world space even when attached

When I attach a USplineMeshComponent to anoter component and call the SetStartAndEnd function, it doesn’t work as expected and use the values passed in world space, and not local space as the documentation suggests.

Here is an example where I make spline meshes follow a spline:

void ATrackBase::OnConstruction(const FTransform& Transform)
{
	USplineMeshComponent* Piece;

	const int32 NumPieces = Path->GetNumSplinePoints() - 1;
	for (int32 iPiece = 0; iPiece < NumPieces; ++iPiece)
	{
		FVector StartLocation, EndLocation;
		FVector StartTangent, EndTangent;

		//In world space (actually, not sure about tangents)
		//StartLocation = Path->GetWorldLocationAtSplinePoint(iPiece);
		//EndLocation = Path->GetWorldLocationAtSplinePoint(iPiece+1);
		//StartTangent = Path->SplineInfo.Points[iPiece].LeaveTangent;
		//EndTangent = Path->SplineInfo.Points[iPiece+1].ArriveTangent;

		//In local space
		Path->GetLocalLocationAndTangentAtSplinePoint(iPiece, StartLocation, StartTangent);
		Path->GetLocalLocationAndTangentAtSplinePoint(iPiece+1, EndLocation, EndTangent);

		Piece = NewObject<USplineMeshComponent>(this);
		Piece->SetStaticMesh(Mesh);
		Piece->AttachTo(Path);
		Piece->RegisterComponent();
		Piece->bCreatedByConstructionScript = true;

		Piece->SetStartAndEnd(StartLocation, StartTangent, EndLocation, EndTangent);
	}
}

If I do the same in Blueprints, the values in local space work fine, as below:

The only difference I see between the code and blueprint versions is the use of AddComponent node, I looked at it’s source but can’t see how that’s different from what I’m doing. Am I attaching components incorrectly in code?