user19458: Normally the e or g pawn must be moved (to release the bishop) before castling kingside is possible. However, it’s theoretically possible for a knight to have taken the bishop without these pawns ever moving, and thus for short castles to be played with the pawns remaining in place.
Silly example:
[FEN ""]

1. Nf3 Nf6 2. Ng5 a6 3. Ne6 a5 4. Nxf8 a4 5. Ne6 a3 6. Ng5 O-O

Is this known to have ever happened in a real game?

user17823: This CQL query:
cql(input Mega_Database_2022.pgn)

flipcolor {
    {
        move from K o-o
        Pg2 Pe2
    } or {
        move from K o-o-o
        Pb2 Pd2
    }
}

returns 224 (!) games when run against Mega Database 2022. There are no games where O-O-O occurred with the pawns in b, d files unmoved.
Only in two of these 224 games it was White who castled with pawns on g2, e2:
[Event "Montigny le Bretonneux op"]
[Site "Montigny le Bretonneux"]
[Date "1999.??.??"]
[Round "4"]
[White "Trifigny, Yves"]
[Black "Edery, Laurent"]
[Result "0-1"]
[ECO "A80"]
[EventDate "1999.11.??"]
[FEN ""]
[StartPly "28"]

1.d4 f5 2.c3 b6 3.Bg5 h6 4.Bf4 Nf6 5.Nd2 Bb7 6.f3 e6 7.Qc2 Nd5 8.Nh3 g5 9.Be5 
Rg8 10.Bg3 Ne3 11.Qd3 Nxf1 12.Nxf1 d5 13.Nd2 Bd6 14.Be5 Qe7 15.O-O 
Nd7 16.Bxd6 Qxd6 17.c4 g4 18.fxg4 dxc4 19.Nxc4 Qc6 20.Rf2 Rxg4 21.Rf3 O-O-O 22.
Nf4 Rxf4 23.Raf1 Rxf3 24.exf3 Qd5 25.b4 Ne5 26.Nxe5 Qxe5 27.Rd1 Qd5 28.Rd2 b5 
29.a3 Rg8 30.Rf2 h5 31.h4 Qc4 32.Qe3 Bd5 33.Kh2 Rg6 34.g3 Bb7 35.Rd2 Qc6 36.Rd3
Qxf3 37.Rc3 Qd5 38.Rc5 Qa2+ 0-1


[Event "Izmir op 12th"]
[Site "Izmir"]
[Date "2013.09.06"]
[Round "7"]
[White "Lorparizangeneh, Shahin"]
[Black "Canbulan, Arda"]
[Result "1-0"]
[WhiteElo "2234"]
[BlackElo "1868"]
[ECO "A52"]
[EventDate "2013.09.01"]
[FEN ""]
[StartPly "36"]

1.d4 Nf6 2.c4 e5 3.dxe5 Ng4 4.Bf4 Bb4+ 5.Nd2 d6 6.Nf3 dxe5 7.Bg3 e4 8.a3 Bxd2+ 
9.Nxd2 e3 10.fxe3 Nxe3 11.Qb3 Qe7 12.Bf4 Nxf1 13.Nxf1 Nc6 14.Ne3 O-O 15.Nd5 Qe4
16.Qd3 Bf5 17.Qxe4 Bxe4 18.Nxc7 Rad8 19.O-O Nd4 20.Rf2 Ne6 21.Nxe6 
1-0

In the rest, Black was castling. Most of them were ECOs B17:
[FEN ""]

1.e4 c6 2.d4 d5 3.Nc3 dxe4 4.Nxe4 Nd7 5.Ng5 h6 6.Ne6 Qb6 7.Nxf8

I had to filter these out with not eco "B17". Here are some unique examples:
[Event "YUG-ch (Women)"]
[Site "Budva"]
[Date "2002.??.??"]
[Round "?"]
[White "Grujic, Danijela"]
[Black "Laketic, Milica"]
[Result "0-1"]
[WhiteElo "2180"]
[BlackElo "2130"]
[ECO "B02"]
[EventDate "2002.08.??"]
[StartPly "35"]
[FEN ""]

1.e4 Nf6 2.Nc3 d5 3.e5 Nfd7 4.e6 fxe6 5.d4 c5 6.Nf3 Nc6 7.Bb5 a6 8.Bxc6 bxc6 9.
g4 Qc7 10.Qe2 cxd4 11.Nxd4 e5 12.Ne6 Qd6 13.Nxf8 Nxf8 14.Bd2 Ne6 15.O-O-O Nd4 
16.Qe3 Bxg4 17.Rde1 Nf3 18.Nd1 18...O-O 19.Ref1 d4 20.Qb3+ Be6 21.Qa4
Bd5 22.Ba5 c5 23.h3 Rab8 24.b3 c4 25.Nb2 c3 26.Nc4 Qh6+ 27.Kb1 Rfc8 28.Ka1 Bxc4
29.bxc4 Nd2 30.Re1 Qc6 31.c5 Qxc5 32.a3 Qb5 33.Qxb5 Rxb5 34.Bb4 Kf7 35.f4 e4 
36.Rh2 d3 37.Rg2 a5 38.Bxe7 Kxe7 39.Rxg7+ Kf6 40.Rxh7 Rcb8 41.Rh6+ Kg7 42.Re6 
Rb1+ 43.Rxb1 Rxb1+ 44.Ka2 Rb2+ 45.Ka1 Rxc2 46.f5 Nb3+ 47.Kb1 Rb2# 0-1


[Event "Wch Seniors 19th"]
[Site "Condino"]
[Date "2009.10.29"]
[Round "3"]
[White "Arkhangelsky, Boris Nikolaevich"]
[Black "Danner, Georg"]
[Result "1/2-1/2"]
[WhiteElo "2292"]
[BlackElo "2440"]
[ECO "B57"]
[EventDate "2009.10.27"]
[FEN ""]
[StartPly "35"]

1.e4 c5 2.Nf3 Nc6 3.d4 cxd4 4.Nxd4 Nf6 5.Nc3 d6 6.Bc4 Na5 7.Bb5+ Bd7 8.Qe2 Rc8 
9.Bg5 Bxb5 10.Qxb5+ Nd7 11.Qe2 Nc4 12.O-O h6 13.Ne6 Qa5 14.Nxf8 Nxf8 15.Bc1 Ne6
16.Nd5 Qd8 17.b3 Ne5 18.Bb2 O-O 19.Rad1 f6 20.c4 b6 21.f4 Nd7 
22.e5 fxe5 23.fxe5 Rxf1+ 24.Qxf1 dxe5 25.Qe2 Nc7 26.Qg4 h5 27.Qh3 Qe8 28.Nb4 
Nf6 29.Bxe5 Ng4 30.Qg3 Rd8 31.Re1 Nxe5 32.Qxe5 Rd7 33.h3 Qg6 34.Nd5 Nxd5 35.
cxd5 Kh7 36.Re3 Qf7 1/2-1/2


[Event "Agosto de Victorias op"]
[Site "Mayabeque"]
[Date "2018.08.07"]
[Round "8"]
[White "Hernandez Sosa, Oscar Luis"]
[Black "Gutierrez Espinosa, Karen"]
[Result "1-0"]
[WhiteElo "2055"]
[BlackElo "2061"]
[ECO "A31"]
[EventDate "2018.08.04"]
[FEN ""]
[StartPly "25"]

1.c4 Nf6 2.Nc3 c5 3.Nf3 b6 4.d4 cxd4 5.Nxd4 Bb7 6.Bg5 Nc6 7.e4 d6 8.Be2 Nd7 9.
O-O h6 10.Ne6 Qc8 11.Nxf8 Nxf8 12.Be3 Ng6 13.f4 O-O 14.Bg4 Qd8 
15.Rf3 e6 16.Rg3 Nge7 17.Bh3 f5 18.Qh5 Kh8 19.Rd1 a6 20.e5 d5 21.cxd5 exd5 22.
Nxd5 Nxd5 23.Qg6 Qe7 24.Rxd5 Rac8 25.Bxf5 Rxf5 26.Qxf5 Qb4 27.Rd1 Qc4 28.Qd7 
Rg8 29.Qxb7 Qe2 30.Rf1 1-0


19458: <p>Normally the e or g pawn must be moved (to release the bishop) before castling kingside is possible. However, it’s theoretically possible for a knight to have taken the bishop without these pawns ever moving, and thus for short castles to be played with the pawns remaining in place.</p>
<p>Silly example:</p>
<pre><code>[FEN &quot;&quot;]

1. Nf3 Nf6 2. Ng5 a6 3. Ne6 a5 4. Nxf8 a4 5. Ne6 a3 6. Ng5 O-O
</code></pre>
<p>Is this known to have ever happened in a real game?</p>
 17823: <p>This <a href="http://gadycosteff.com/cql" rel="noreferrer">CQL</a> query:</p>
<pre><code>cql(input Mega_Database_2022.pgn)

flipcolor {
    {
        move from K o-o
        Pg2 Pe2
    } or {
        move from K o-o-o
        Pb2 Pd2
    }
}
</code></pre>
<p>returns <a href="https://gist.github.com/double-beep/caf1971d6c5b8ec4fdd27a992d61853b" rel="noreferrer">224 (!) games</a> when run against Mega Database 2022. There are no games where O-O-O occurred with the pawns in b, d files unmoved.</p>
<p>Only in two of these 224 games it was White who castled with pawns on g2, e2:</p>
<pre><code>[Event &quot;Montigny le Bretonneux op&quot;]
[Site &quot;Montigny le Bretonneux&quot;]
[Date &quot;1999.??.??&quot;]
[Round &quot;4&quot;]
[White &quot;Trifigny, Yves&quot;]
[Black &quot;Edery, Laurent&quot;]
[Result &quot;0-1&quot;]
[ECO &quot;A80&quot;]
[EventDate &quot;1999.11.??&quot;]
[FEN &quot;&quot;]
[StartPly &quot;28&quot;]

1.d4 f5 2.c3 b6 3.Bg5 h6 4.Bf4 Nf6 5.Nd2 Bb7 6.f3 e6 7.Qc2 Nd5 8.Nh3 g5 9.Be5 
Rg8 10.Bg3 Ne3 11.Qd3 Nxf1 12.Nxf1 d5 13.Nd2 Bd6 14.Be5 Qe7 15.O-O 
Nd7 16.Bxd6 Qxd6 17.c4 g4 18.fxg4 dxc4 19.Nxc4 Qc6 20.Rf2 Rxg4 21.Rf3 O-O-O 22.
Nf4 Rxf4 23.Raf1 Rxf3 24.exf3 Qd5 25.b4 Ne5 26.Nxe5 Qxe5 27.Rd1 Qd5 28.Rd2 b5 
29.a3 Rg8 30.Rf2 h5 31.h4 Qc4 32.Qe3 Bd5 33.Kh2 Rg6 34.g3 Bb7 35.Rd2 Qc6 36.Rd3
Qxf3 37.Rc3 Qd5 38.Rc5 Qa2+ 0-1
</code></pre>
<hr />
<pre><code>[Event &quot;Izmir op 12th&quot;]
[Site &quot;Izmir&quot;]
[Date &quot;2013.09.06&quot;]
[Round &quot;7&quot;]
[White &quot;Lorparizangeneh, Shahin&quot;]
[Black &quot;Canbulan, Arda&quot;]
[Result &quot;1-0&quot;]
[WhiteElo &quot;2234&quot;]
[BlackElo &quot;1868&quot;]
[ECO &quot;A52&quot;]
[EventDate &quot;2013.09.01&quot;]
[FEN &quot;&quot;]
[StartPly &quot;36&quot;]

1.d4 Nf6 2.c4 e5 3.dxe5 Ng4 4.Bf4 Bb4+ 5.Nd2 d6 6.Nf3 dxe5 7.Bg3 e4 8.a3 Bxd2+ 
9.Nxd2 e3 10.fxe3 Nxe3 11.Qb3 Qe7 12.Bf4 Nxf1 13.Nxf1 Nc6 14.Ne3 O-O 15.Nd5 Qe4
16.Qd3 Bf5 17.Qxe4 Bxe4 18.Nxc7 Rad8 19.O-O Nd4 20.Rf2 Ne6 21.Nxe6 
1-0
</code></pre>
<p>In the rest, Black was castling. Most of them were ECOs B17:</p>
<pre><code>[FEN &quot;&quot;]

1.e4 c6 2.d4 d5 3.Nc3 dxe4 4.Nxe4 Nd7 5.Ng5 h6 6.Ne6 Qb6 7.Nxf8
</code></pre>
<p>I had to filter these out with <code>not eco &quot;B17&quot;</code>. Here are some unique examples:</p>
<pre><code>[Event &quot;YUG-ch (Women)&quot;]
[Site &quot;Budva&quot;]
[Date &quot;2002.??.??&quot;]
[Round &quot;?&quot;]
[White &quot;Grujic, Danijela&quot;]
[Black &quot;Laketic, Milica&quot;]
[Result &quot;0-1&quot;]
[WhiteElo &quot;2180&quot;]
[BlackElo &quot;2130&quot;]
[ECO &quot;B02&quot;]
[EventDate &quot;2002.08.??&quot;]
[StartPly &quot;35&quot;]
[FEN &quot;&quot;]

1.e4 Nf6 2.Nc3 d5 3.e5 Nfd7 4.e6 fxe6 5.d4 c5 6.Nf3 Nc6 7.Bb5 a6 8.Bxc6 bxc6 9.
g4 Qc7 10.Qe2 cxd4 11.Nxd4 e5 12.Ne6 Qd6 13.Nxf8 Nxf8 14.Bd2 Ne6 15.O-O-O Nd4 
16.Qe3 Bxg4 17.Rde1 Nf3 18.Nd1 18...O-O 19.Ref1 d4 20.Qb3+ Be6 21.Qa4
Bd5 22.Ba5 c5 23.h3 Rab8 24.b3 c4 25.Nb2 c3 26.Nc4 Qh6+ 27.Kb1 Rfc8 28.Ka1 Bxc4
29.bxc4 Nd2 30.Re1 Qc6 31.c5 Qxc5 32.a3 Qb5 33.Qxb5 Rxb5 34.Bb4 Kf7 35.f4 e4 
36.Rh2 d3 37.Rg2 a5 38.Bxe7 Kxe7 39.Rxg7+ Kf6 40.Rxh7 Rcb8 41.Rh6+ Kg7 42.Re6 
Rb1+ 43.Rxb1 Rxb1+ 44.Ka2 Rb2+ 45.Ka1 Rxc2 46.f5 Nb3+ 47.Kb1 Rb2# 0-1
</code></pre>
<hr />
<pre><code>[Event &quot;Wch Seniors 19th&quot;]
[Site &quot;Condino&quot;]
[Date &quot;2009.10.29&quot;]
[Round &quot;3&quot;]
[White &quot;Arkhangelsky, Boris Nikolaevich&quot;]
[Black &quot;Danner, Georg&quot;]
[Result &quot;1/2-1/2&quot;]
[WhiteElo &quot;2292&quot;]
[BlackElo &quot;2440&quot;]
[ECO &quot;B57&quot;]
[EventDate &quot;2009.10.27&quot;]
[FEN &quot;&quot;]
[StartPly &quot;35&quot;]

1.e4 c5 2.Nf3 Nc6 3.d4 cxd4 4.Nxd4 Nf6 5.Nc3 d6 6.Bc4 Na5 7.Bb5+ Bd7 8.Qe2 Rc8 
9.Bg5 Bxb5 10.Qxb5+ Nd7 11.Qe2 Nc4 12.O-O h6 13.Ne6 Qa5 14.Nxf8 Nxf8 15.Bc1 Ne6
16.Nd5 Qd8 17.b3 Ne5 18.Bb2 O-O 19.Rad1 f6 20.c4 b6 21.f4 Nd7 
22.e5 fxe5 23.fxe5 Rxf1+ 24.Qxf1 dxe5 25.Qe2 Nc7 26.Qg4 h5 27.Qh3 Qe8 28.Nb4 
Nf6 29.Bxe5 Ng4 30.Qg3 Rd8 31.Re1 Nxe5 32.Qxe5 Rd7 33.h3 Qg6 34.Nd5 Nxd5 35.
cxd5 Kh7 36.Re3 Qf7 1/2-1/2
</code></pre>
<hr />
<pre><code>[Event &quot;Agosto de Victorias op&quot;]
[Site &quot;Mayabeque&quot;]
[Date &quot;2018.08.07&quot;]
[Round &quot;8&quot;]
[White &quot;Hernandez Sosa, Oscar Luis&quot;]
[Black &quot;Gutierrez Espinosa, Karen&quot;]
[Result &quot;1-0&quot;]
[WhiteElo &quot;2055&quot;]
[BlackElo &quot;2061&quot;]
[ECO &quot;A31&quot;]
[EventDate &quot;2018.08.04&quot;]
[FEN &quot;&quot;]
[StartPly &quot;25&quot;]

1.c4 Nf6 2.Nc3 c5 3.Nf3 b6 4.d4 cxd4 5.Nxd4 Bb7 6.Bg5 Nc6 7.e4 d6 8.Be2 Nd7 9.
O-O h6 10.Ne6 Qc8 11.Nxf8 Nxf8 12.Be3 Ng6 13.f4 O-O 14.Bg4 Qd8 
15.Rf3 e6 16.Rg3 Nge7 17.Bh3 f5 18.Qh5 Kh8 19.Rd1 a6 20.e5 d5 21.cxd5 exd5 22.
Nxd5 Nxd5 23.Qg6 Qe7 24.Rxd5 Rac8 25.Bxf5 Rxf5 26.Qxf5 Qb4 27.Rd1 Qc4 28.Qd7 
Rg8 29.Qxb7 Qe2 30.Rf1 1-0
</code></pre>
