Смотрите, в чем дело. Эта программа содержит неопределенное поведение из-за несоответствия спецификаторов формата и фактических аргументов в вызове функции printf. Стандарт не налагает никаких ограничений на поведение программы, содержащей неопределенное поведение. Однако мы можем по-рассуждать, почему в вашем конкретном случае программа выводит -13. Тип assignment expression (т. е. 3) является типом выражения с левой стороны (т. е. Выражение справа преобразуется в тип assignment expression и затем замещает значение в объекте, на который указывает операнд слева (т. е. Другими словами выражение справа типа int неявно преобразуется в тип unsigned int. Т. е. в переменную a никогда не попадет значение -3 типа int, оно будет неявно преобразовано в тип unsigned int перед присваиванием. MAX, которое само уже зависит от реализации. Далее — выражение a — 10. Здесь имеют место usual arithmetic conversions (§ 6.3.1.8), в ходе которых операнд 10 типа signed int преобразуется в unsigned int. Далее. При вызове функции с переменным числом аргументов (каковой и является printf) происходит процесс, который называется default argument promotions (§ 6.5.2.2 / 6), при котором каждый аргумент проходит преобразование в некоторый тип и только затем, в преобразованном виде, передается на вход функции. Согласно правилам таких преобразований аргумент a в данном случае не будет преобразован ни в какой другой тип, т. е. Здесь возникает проблема: функция printf ожидает на входе тип int (потому что мы указали спецификатор %d в формате), но мы её на вход передаем тип unsigned int. Все, что произойдет далее зависит от того, как сложатся звезды как реализована функция printf. Можем сделать некоторые предположения. В данном случае — это 4 байта 0xFFFFFFF3. Если эти 4 байта интерпретировать как int в two’s complement (что и вынуждена делать функция printf в нашем примере), то получится как раз -13. MAX — это в случае unsigned int. 3 Все ссылки в данном ответе предполагают рабочий черновик стандарта ISO/IEC 9899:202x (E) от 7-го июня 2019 года. 10 тоже подвергается преобразованию в unsigned int. На результат этот не повлияет и для простоты вычислений закроем глаза на этот нюанс.
n
Can I use 7-Zip in a commercial organization? Yes, 7-Zip is free software. You can use it on any computer. How can I set file associations to 7-Zip in Windows 7 and Windows Vista? You must run 7-Zip File Manager in administrator mode. Right-click the icon of 7-Zip File Manager, and then click Run as administrator. Then you can change file associations and some other options. Why 7z archives created by new version of 7-Zip can be larger than archives created by old version of 7-Zip? New versions of 7-Zip (starting from version 15.06) use another file sorting order by default for solid 7z archives. Old version of 7-Zip (before version 15.06) used file sorting «by type» («by extension»). Parameters field in «Add to archive» window, (or -mqs switch for command line version). You can get big difference in compression ratio for different sorting methods, if dictionary size is smaller than total size of files.
n
If there are similar files in different folders, the sorting «by type» can provide better compression ratio in some cases. Note that sorting «by type» has some drawbacks. For example, NTFS volumes use sorting order «by name», so if an archive uses another sorting, then the speed of some operations for files with unusual order can fall on HDD devices (HDDs have low speed for «seek» operations). Increase dictionary size. It can help when ‘qs’ is not used. Specify ‘qs’ in Parameters field (or use -mqs switch for command line version). If you think that unusual file order is not problem for you, and if better compression ratio with small dictionary is more important for you, use ‘qs’ mode. Why can’t 7-Zip open some ZIP archives? In 99% of these cases it means that the archive contains incorrect headers. Other ZIP programs can open some archives with incorrect headers, since these programs just ignore errors.
n
If you have such archive, please don’t call the 7-Zip developers about it. Instead try to find the program that was used to create the archive and inform the developers of that program that their software is not ZIP-compatible. There are also some ZIP archives that were encoded with methods unsupported by 7-Zip, for example, WAVPack (WinZip). Why can’t 7-Zip open some RAR archives? 7-Zip 9.20 supports RAR 2/3/4 formats only and doesn’t support RAR5 archives. But latest versions of 7-Zip supports RAR5 archives. Why does drag-and-drop archive extraction from 7-Zip to Explorer use temp files? 7-Zip doesn’t know folder path of drop target. Only Windows Explorer knows exact drop target. And Windows Explorer needs files (drag source) as decompressed files on disk. So 7-Zip extracts files from archive to temp folder and then 7-Zip notifies Windows Explorer about paths of these temp files. Then Windows Explorer copies these files to drop target folder.
n