"This sentence has five words and this sentence has five words." In English "this" need not always be self referential, so I'll retort with "This sentence is imprecise".
The two "this"s could refer to two different things. However, the second this would normally become that to indicate comparison but grammatically the original is still sound [with notes]:
This sentence [indicates a sentence with five words in it] has five words and this sentence [indicates another sentence, also with five words in it] has five words.