Bug 249723

Summary: sscanf(str, "%as", &charptr) broken with --std=gnu99
Product: [Fedora] Fedora Reporter: Peter Jones <pjones>
Component: gccAssignee: Jakub Jelinek <jakub>
Status: CLOSED NOTABUG QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: low Docs Contact:
Priority: low    
Version: rawhideKeywords: Reopened
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2007-07-27 07:25:12 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
this is a fix. none

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.