You could index a with c, but would need to remove the negative values from a, as gather expects positive indices:
device = 'cuda'
a = torch.tensor([1, 0, 3, 2, 4], device=device)
b = torch.tensor([4, 5, 6, 7, 8], device=device)
c = torch.tensor([0, 0, 0, 1, -1, 3, 4], device=device)

res = torch.gather(b, 0, a[c])
print(res)
> tensor([5, 5, 5, 4, 8, 6, 8], device='cuda:0')

I’m also unsure about your expected result tensor, as the -1 in c would index a at the last position and b[4] would be 8 not 7.