  Direct observations of gaseous exoplanets reveals that their gas envelope is
commonly enriched in C/O ratio compared to that of the host star. This has been
explained by considering that the gas phase of the disc could be inhomogeneous,
exceeding the stellar C/O ratio in regions where these planets formed; but few
studies have considered the drift of the gas and the migration of planets. We
aim to derive the gas composition in planets to evaluate if the formation of
giant planets with an enriched C/O ratio is possible. The study focusses on the
effects of different processes on the C/O ratio like the disc evolution, the
drift of gas, and the migration of the planet. We used our previous models for
computation of the chemical composition together with the planet formation
model of Alibert et al. (2013), to which we added the composition and drift of
the gas phase of the disc composed of major volatile species, H2 and He. The
study focusses on the region where ice lines are present and influence the C/O
ratio of the planets. Modelling shows that the condensation of volatile species
allows for C/O enrichment in specific parts of the protoplanetary disc, of up
to 4 times the solar value. This leads to the formation of planets that can be
enriched in C/O in their envelope up to 3 times the solar value. The migration
of planets, the evolution of the gas phase, and the irradiation of the disc
enables the evolution of the initial C/O ratio with a decrease in the outer
part of the disc and an increase in the inner part. The total C/O ratio of the
planets is governed by the contribution of ices accreted, suggesting that high
C/O ratios measured in planetary atmospheres are indicative of a lack of
exchange of material between the core of a planet and its envelope or an
observational bias, and suggesting that the observed C/O ratio is not
representative of the total C/O ratio of the planet.
