I executed your code with VCS and it works fine. Which tool are you using? Is it giving compile error or constraint failure error? Are there any other conflicting constraints?
Also note that the older version of simulators does not support unique keyword. I just copy-pasted the sample code, and it works fine on VCS on EDAPlaygound (but throws compile error in Riviera):
module top();
class A;
rand byte a,b[10],c;
constraint ab {unique {a,b[2:5],c};}
constraint c1{c==5;}
endclass
A obj = new();
initial
begin
repeat(5)
begin
if(!obj.randomize())
begin
$display("Unable to randomize");
$finish;
end
$display("a = %0p",obj);
end
end
endmodule
// Output:
a = '{a:92, b:'{-7, -105, -54, 23, -114, 54, 106, -90, 31, -119} , c:5}
a = '{a:42, b:'{-35, 9, 119, -35, 126, -36, -81, -89, -125, 111} , c:5}
a = '{a:107, b:'{92, -26, -113, 59, -122, -27, 75, -93, -128, -47} , c:5}
a = '{a:-27, b:'{6, 114, 14, 77, 52, 28, -96, -77, -33, 92} , c:5}
a = '{a:87, b:'{-98, -44, 16, -59, -57, -121, 59, -37, 110, -42} , c:5}
Also, the same example is provided in IEEE 1800-2012 Section 18.5.5. So, I doubt there might be some simulator issue.