Only effects Creative mode.
Only effects item "held" by your cursor in inventory GUIs.
Edit: Upon further testing, this bug ceased to exist after rebooting the game.
To replicate this bug, put down a command block with the command "/clear [username] [any valid item ID]".
Hook a redstone clock to the command block, and open your inventory. Click on any item, and it gets deleted, even though it is not the item the command is supposed to clear.
Duplicate of MC-18627 - If you have not, please use the search function in the future, to see if your bug has already been submitted. If you could not find the original report, please comment with the keywords you searched for.