| t | <hr size=2> | t | |
| <dl><dt> Subject</dt> | | |
| <dd> AI makes copy-paste errors</dd> | | |
| <dt> Date</dt> | | |
| <dd> 2026-04-25_16:01:26.25</dd> | | |
| <dt> Tags</dt> | | |
| <dd> Linux, ai, coding</dd> | | |
| <dt> Author</dt> | | |
| <dd> tbird20d</dd> | | |
| </dl><hr size=2> | | |
| I recently submitted a patch to the Linux kernel that included some assembly | | |
| code for accessing clock hardware early in kernel initialization. Another | | |
| developer gave some feedback indicating that I should preface the clock | | |
| access instructions with memory barrier instructions, to avoid race conditions | | |
| with other code. However, my code only runs before SMP starts, so it's not | | |
| possible for such a race condition to occur. | | |
| <p> | | |
| I suspect the developer either copied the code from somewhere else, or used | | |
| AI to generate the code for the assembly instructions that he suggested. | | |
| <p> | | |
| After thinking about this, it occurred to me that the most likely type of | | |
| errors that AI is going to make in creating new code are "copy-paste" errors. | | |
| These are a type of error where code is copied from one place and used | | |
| in another place, but the conditions in the new place are different, either | | |
| syntactically or semantically. AI seems adept at handling syntactic differences, | | |
| such as indenting the code properly or renaming variables. | | |
| <p> | | |
| But it's not intelligent enough to handle different semantics in complex | | |
| situations. If the human doesn't have the experience to detect such things | | |
| , which can often be quite subtle, then it results in "copy-paste"-type bugs, | | |
| where the current code is incorrect or sub-optimal for its current location. | | |
| <p> | | |
| This problem is due to LLMs and AI coders being able to pull stuff from their | | |
| training data, but not actually understand the code at a deeper level. But | | |
| AI coders are getting better and better, and they already detect subtle problems | | |
| that the average or even experienced coder might miss. | | |
| <p> | | |