Wolfram Language (Mathematica), 50 47 42 2525 27 bytes
{}⋃Select[x/.Solve[#~FromDigits~x==0],IntegerQ]&
Update: using Luis Mendo's fact, golfed off another 3 bytes
Pick[r=Range[s=-Tr@Abs@#,-s],#~FromDigits~r,0]&
Getting sloppier with the bounds, we can reduce this 5 more bytes per @Not a tree's suggestion:
Pick[r=Range[s=-#.#,-s],#~FromDigits~r,0]&
After posting this, OP commented allowing "native polynomials", so here's a 25 byte solution that accepts the polynomial as input. This works because by default Mathematica factors polynomials over the integers, and any rational roots show up in a form like m*x+b
that fails the pattern match.
Cases[Factor@#,b_+x:>-b]&
Try it online! As @alephalpha pointed out this will fail for the case where zero is a root, so to fix that we can use the Optional
symbol :
Cases[Factor@#,b_:0+x:>-b]&
This parses fine Mathematica 11.0.1 but fails and requires an extra set of parentheses around b_:0
in version 11.2. This takes up back up to 27 bytes, plus two more after version 11.0.1. It looks like a "fix" was put in here