Bug 249723 - sscanf(str, "%as", &charptr) broken with --std=gnu99
Summary: sscanf(str, "%as", &charptr) broken with --std=gnu99
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Fedora
Classification: Fedora
Component: gcc
Version: rawhide
Hardware: All
OS: Linux
low
low
Target Milestone: ---
Assignee: Jakub Jelinek
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2007-07-26 17:31 UTC by Peter Jones
Modified: 2007-11-30 22:12 UTC (History)
0 users

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2007-07-27 07:25:12 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)
this is a fix. (534 bytes, patch)
2007-07-26 17:31 UTC, Peter Jones
no flags Details | Diff

Description Peter Jones 2007-07-26 17:31:04 UTC
Description of problem:

the type checking for sscanf() doesn't allow "%as" when invoked with --std=gnu99.

Version-Release number of selected component (if applicable):

4.1.2-20070704 .

A patch is attached to this bug which I think correctly fixes this issue.

Comment 1 Peter Jones 2007-07-26 17:31:04 UTC
Created attachment 160047 [details]
this is a fix.

Comment 2 Jakub Jelinek 2007-07-26 17:48:31 UTC
That code is intentional, glibc violates the C99 standard by this.
The upcoming POSIX standard will use m modified instead (so %ms, %mS, %mls, %m[)
and glibc will soon implement it.  ATM I have a few questions about the exact
wording and unclear description of memory allocation failure handling case
(which will be different from glibc's %as/%aS/%a[ modifier handling), once
that's resolved we'll implement it in glibc and also in gcc format checking
(the m modifier letter has been cleared with ISO groups already).

Comment 3 Peter Jones 2007-07-26 23:47:19 UTC
Well, yeah, it's a gnu extension -- that's why --std is set to gnu99, not c99 or
similar.  The current behavior is directly contrary to the current documentation.

Comment 4 Jakub Jelinek 2007-07-27 07:25:12 UTC
But it is a GNU extension that violates the standard, -std=gnu99 generally
enables extensions to the standard that don't conflict with the standard.
The warning is still very useful to inform people about the extension conflict
with the standard.
When we implement the m modifier, the intent is for the strict modes to not
accept %as, %aS and %a[ any longer (have a separate set of *scanf entrypoints
for that mode) and people really should be aware of this.
Hopefully they will switch to using %ms, %mS, %m[ soon to get rid of the warning,
which is the intent.


Note You need to log in before you can comment on or make changes to this bug.