Do there exist smooth compact (=complete) connected complex algebraic varieties $X\subset Y$ and a Zariski neighborhood $U$ of $X$ in $Y$ such that the image of $H^{\ast}(U,\mathbf{Z})$ in $H^{\ast}(X,\mathbf{Z})$ under the restriction map is different from the image of $H^*(Y,\mathbf{Z})$?
Remark: if one considers the rational cohomology instead of the integral one, the answer is no by Hodge theory: if a class on $X$ comes from a class on $U$, it is the restriction of a class of the "right" weight and hence it extends from $U$ to any smooth compactification, in particular to $Y$. In this argument it is important that cohomology maps induced by regular maps of algebraic varieties are strictly compatible with the weight filtrations: if a weight $k$ class in the target is in the image, then it is the image of a weight $k$ class.
The motivation behind the above question is to understand whether or not the same holds for the integral weight filtrations, which can be defined as the Leray filtrations induced by the open embedding in a compactification as the complement of a divisor with normal crossings, see Weight filtration over the integers.
The above is in a sense the simplest possible situation when strictness may fail. I.e., if the answer to the above question is positive, this would imply that the integral cohomology mappings are not necessarily strictly compatible with the weight filtrations. If the answer is negative, then I would be very interested to know the answer to the same question with "algebraic" replaced with "complex analytic" and "Zariski neighborhood" replaced with "an open set whose complement can be blown up to a divisor with normal crossings".